From 034c9f398ad5cc820485c42f419dd6c3a4debaca Mon Sep 17 00:00:00 2001 From: testbetter <50055806+testbetter@users.noreply.github.com> Date: Mon, 10 May 2021 09:47:41 -0500 Subject: [PATCH 01/38] Create codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..5c7d968 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,71 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '24 1 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # âœī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From d79ec1c1f1c724e56d36618b8bf45288008c3bc0 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 11 May 2021 12:14:46 +0530 Subject: [PATCH 02/38] fixed content-length issue --- src/superClient.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/superClient.js b/src/superClient.js index b9180dc..108b7db 100644 --- a/src/superClient.js +++ b/src/superClient.js @@ -27,8 +27,15 @@ module.exports = async function superClient( } else if (basicAuth) { suObj = suObj.auth(basicAuth.username || '', basicAuth.password || ''); } - return suObj - .set(req.header || '') - .send(data) - .sortQuery(); + + suObj.set(req.header || ''); + + // Only set data if data has some value, so that content-length is zero + if (data && data !== 'null' && Object.keys(data).length > 0) { + suObj.send(data); + } + + suObj.sortQuery(); + + return suObj; }; From 1cd9186e0372ec7a69fba3ee2757c729e177ca8a Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 11 May 2021 12:14:56 +0530 Subject: [PATCH 03/38] updated packages --- package.json | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 6f97df7..fe0791c 100644 --- a/package.json +++ b/package.json @@ -16,15 +16,14 @@ "openapitest": "./bin/openapitest.js" }, "repository": { - "type" : "git", - "url" : "git+https://github.com/testbetter/openapitest.git" + "type": "git", + "url": "git+https://github.com/testbetter/openapitest.git" }, "keywords": [ "operapi", "swagger", "integration test" ], - "author": "Test Better", "author": { "name": "Test Better", "email": "testbetter100@gmail.com" @@ -34,27 +33,27 @@ }, "license": "MIT", "dependencies": { - "chai": "^4.2.0", + "chai": "^4.3.4", "colors": "^1.4.0", - "commander": "^2.20.1", + "commander": "^7.2.0", "expect.js": "^0.3.1", - "faker": "^4.1.0", - "js-yaml": "^3.13.1", - "jsonpath": "^1.0.0", + "faker": "^5.5.3", + "js-yaml": "^4.1.0", + "jsonpath": "^1.1.1", "klaw-sync": "^6.0.0", - "lodash": "^4.17.14", - "mocha": "^5.2.0", - "mochawesome": "^3.1.2", - "object-path": "^0.11.3", - "object-values": "^1.0.0", - "shelljs": "^0.8.3", - "superagent": "^4.1.0", + "lodash": "^4.17.21", + "mocha": "^8.4.0", + "mochawesome": "^6.2.2", + "object-path": "^0.11.5", + "object-values": "^2.0.0", + "shelljs": "^0.8.4", + "superagent": "^6.1.0", "tryer": "^1.0.1" }, "devDependencies": { - "eslint": "^5.16.0", - "eslint-config-airbnb-base": "^13.2.0", - "eslint-plugin-import": "^2.18.2", - "sinon": "^7.5.0" + "eslint": "^7.26.0", + "eslint-config-airbnb-base": "^14.2.1", + "eslint-plugin-import": "^2.22.1", + "sinon": "^10.0.0" } } From 25cad3dd4e61aeb39275167a3fc5eb3783e2658d Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 11 May 2021 12:15:11 +0530 Subject: [PATCH 04/38] updated version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fe0791c..8978448 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.0.0", + "version": "3.2.0", "description": "", "main": "src/index.js", "scripts": { From efbf9d6fba3e849c63fe4583b3cffb4914dc5c9c Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 11 May 2021 12:15:27 +0530 Subject: [PATCH 05/38] added .idea to gitignore - ide related --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6360e5e..9dcefc4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules/ *~ .DS_Store npm_debug.log +.idea From 2d2529626c95346c4efdf4dba375e387739b9e92 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 11 May 2021 12:29:27 +0530 Subject: [PATCH 06/38] revered package.json version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8978448..4ff4b4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.2.0", + "version": "3.1.0", "description": "", "main": "src/index.js", "scripts": { From da88be3a6054ec95373a6d9a0b94467493f62af5 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 11 May 2021 12:29:37 +0530 Subject: [PATCH 07/38] 3.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ff4b4f..8978448 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.1.0", + "version": "3.2.0", "description": "", "main": "src/index.js", "scripts": { From 8e7c71eee1e42158af7fe8c1c21838e303cb1ec9 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 11 May 2021 14:12:25 +0530 Subject: [PATCH 08/38] reverted commander version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8978448..dd2e272 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "dependencies": { "chai": "^4.3.4", "colors": "^1.4.0", - "commander": "^7.2.0", + "commander": "^2.20.1", "expect.js": "^0.3.1", "faker": "^5.5.3", "js-yaml": "^4.1.0", From 4a91c1a30cec7cd726a84f988c27aa60f7f806a3 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 11 May 2021 14:14:10 +0530 Subject: [PATCH 09/38] 3.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dd2e272..8d51ad3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.2.0", + "version": "3.2.1", "description": "", "main": "src/index.js", "scripts": { From a27c898d1f5eedda7b5966964563e1bc94c89a3e Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 11 May 2021 14:18:54 +0530 Subject: [PATCH 10/38] reverted js-yaml package --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8d51ad3..769eafc 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "commander": "^2.20.1", "expect.js": "^0.3.1", "faker": "^5.5.3", - "js-yaml": "^4.1.0", + "js-yaml": "^3.13.1", "jsonpath": "^1.1.1", "klaw-sync": "^6.0.0", "lodash": "^4.17.21", From ebbeccb9aafb0e71cc4eccf4f12ed922c509b14f Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 11 May 2021 14:21:09 +0530 Subject: [PATCH 11/38] 3.2.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 769eafc..b64e86b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.2.1", + "version": "3.2.2", "description": "", "main": "src/index.js", "scripts": { From d02764eb9002d0ebf9870cab625440226bf3815d Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Thu, 12 Aug 2021 14:15:22 +0530 Subject: [PATCH 12/38] added option for proxy in openapitest.js --- bin/openapitest.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/openapitest.js b/bin/openapitest.js index 44973c8..0e5e887 100755 --- a/bin/openapitest.js +++ b/bin/openapitest.js @@ -35,6 +35,7 @@ program parseInt ) .option('-u, --url [url]', 'Server URL. e.g: http://localhost:9000') + .option('-p, --proxy [proxy]', 'Proxy URL. e.g: http://127.0.0.1:8080') program.parse(process.argv) @@ -72,6 +73,10 @@ if (program.dataConfig) { process.env.COMMON_DATA_CONFIG = program.dataConfig } +if (program.proxy) { + process.env.PROXYURL = program.proxy; +} + process.env.API_SERVER_URL = program.url let options = {} @@ -106,4 +111,4 @@ function checkExists(file, desc) { console.log(`${desc}: ${file} does not exist.`.bold.red) process.exit(-1) } -} \ No newline at end of file +} From b7581978b9e3ca1b9e9f6fdc1d30a6f6fbc3fbcd Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Thu, 12 Aug 2021 14:15:44 +0530 Subject: [PATCH 13/38] implemented superagent-proxy --- src/superClient.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/superClient.js b/src/superClient.js index 108b7db..e18fdcf 100644 --- a/src/superClient.js +++ b/src/superClient.js @@ -1,6 +1,9 @@ /* eslint-disable comma-dangle */ const _ = require('lodash'); const request = require('superagent'); +require('superagent-proxy')(request); + +const proxy = process.env.PROXYURL || null; module.exports = async function superClient( apiPort, @@ -30,6 +33,10 @@ module.exports = async function superClient( suObj.set(req.header || ''); + if (proxy) { + suObj.proxy(proxy); + } + // Only set data if data has some value, so that content-length is zero if (data && data !== 'null' && Object.keys(data).length > 0) { suObj.send(data); From 158107fb27682ae236f6c1106de6abc7cd53653a Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Thu, 12 Aug 2021 14:15:58 +0530 Subject: [PATCH 14/38] changed version --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index b64e86b..060ca6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.2.2", + "version": "4.0", "description": "", "main": "src/index.js", "scripts": { @@ -48,6 +48,7 @@ "object-values": "^2.0.0", "shelljs": "^0.8.4", "superagent": "^6.1.0", + "superagent-proxy": "^2.1.0", "tryer": "^1.0.1" }, "devDependencies": { From 7017104a77dccf7c88568ca22b07c38e5e07468e Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Thu, 12 Aug 2021 14:17:38 +0530 Subject: [PATCH 15/38] added to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0e24c99..940befc 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Options: -g, --globalConfig [path] Global Test data config folder relative/ absolute path. e.g: /global-config -u, --url [url] Server URL. e.g: http://localhost:9000 -r, --report Will generate the html report or not. Default 0; e.g: 1 or 0 + -p, --proxy [proxy] The Proxy URL, e.g: http://127.0.0.1:8080 -h, --help output usage information ``` From 34df1bc010bae86513408636d606c992758d92f3 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Thu, 12 Aug 2021 14:21:41 +0530 Subject: [PATCH 16/38] changed package version to 3.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 060ca6e..d13c2a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "4.0", + "version": "3.3", "description": "", "main": "src/index.js", "scripts": { From a8c8c38d44026f601d2b63c240846f67df278693 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Thu, 12 Aug 2021 14:23:21 +0530 Subject: [PATCH 17/38] changed package version to 3.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d13c2a7..48980e4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.3", + "version": "3.3.0", "description": "", "main": "src/index.js", "scripts": { From 501cb649adc51cd6c6889327989a5a98735f6593 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Thu, 9 Sep 2021 18:50:26 +0530 Subject: [PATCH 18/38] inline mochawesome css in reports --- bin/openapitest.js | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/openapitest.js b/bin/openapitest.js index 0e5e887..11182d4 100755 --- a/bin/openapitest.js +++ b/bin/openapitest.js @@ -88,7 +88,8 @@ if(program.report) { overwrite: true, charts: true, code: false, - quiet: true + quiet: true, + inline: true } } diff --git a/package.json b/package.json index 48980e4..394c307 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.3.0", + "version": "3.3.1", "description": "", "main": "src/index.js", "scripts": { From 8603dea02e6dfc2c2b870f747bbc702d7630ee6e Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Thu, 9 Sep 2021 19:08:03 +0530 Subject: [PATCH 19/38] inline mochawesome css in reports via argument --- bin/openapitest.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/openapitest.js b/bin/openapitest.js index 11182d4..e7c9ccf 100755 --- a/bin/openapitest.js +++ b/bin/openapitest.js @@ -34,6 +34,11 @@ program 'Will generate the html report or not. e.g: 1 or 0', parseInt ) + .option( + '-i, --inline-report-assets ', + 'Inline assets in generated HTML report.', + parseInt + ) .option('-u, --url [url]', 'Server URL. e.g: http://localhost:9000') .option('-p, --proxy [proxy]', 'Proxy URL. e.g: http://127.0.0.1:8080') @@ -77,6 +82,11 @@ if (program.proxy) { process.env.PROXYURL = program.proxy; } +let inlineReportAssets = false; +if (program.inlineReportAssets) { + inlineReportAssets = true; +} + process.env.API_SERVER_URL = program.url let options = {} @@ -89,7 +99,7 @@ if(program.report) { charts: true, code: false, quiet: true, - inline: true + inline: inlineReportAssets } } From e0e69d9d9782eb106af04a37883e2119be43a560 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Thu, 9 Sep 2021 19:10:37 +0530 Subject: [PATCH 20/38] updated readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 940befc..1f98e5e 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Options: -g, --globalConfig [path] Global Test data config folder relative/ absolute path. e.g: /global-config -u, --url [url] Server URL. e.g: http://localhost:9000 -r, --report Will generate the html report or not. Default 0; e.g: 1 or 0 + -i, --inline-report-assets Inline assets in generated HTML report. -p, --proxy [proxy] The Proxy URL, e.g: http://127.0.0.1:8080 -h, --help output usage information ``` From 5cc318d5e781276827be8d2fc276b2fc25d7954e Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Fri, 8 Oct 2021 12:58:35 +0530 Subject: [PATCH 21/38] PR comment addressed --- bin/openapitest.js | 12 +----------- package.json | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/bin/openapitest.js b/bin/openapitest.js index e7c9ccf..11182d4 100755 --- a/bin/openapitest.js +++ b/bin/openapitest.js @@ -34,11 +34,6 @@ program 'Will generate the html report or not. e.g: 1 or 0', parseInt ) - .option( - '-i, --inline-report-assets ', - 'Inline assets in generated HTML report.', - parseInt - ) .option('-u, --url [url]', 'Server URL. e.g: http://localhost:9000') .option('-p, --proxy [proxy]', 'Proxy URL. e.g: http://127.0.0.1:8080') @@ -82,11 +77,6 @@ if (program.proxy) { process.env.PROXYURL = program.proxy; } -let inlineReportAssets = false; -if (program.inlineReportAssets) { - inlineReportAssets = true; -} - process.env.API_SERVER_URL = program.url let options = {} @@ -99,7 +89,7 @@ if(program.report) { charts: true, code: false, quiet: true, - inline: inlineReportAssets + inline: true } } diff --git a/package.json b/package.json index 394c307..78685f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.3.1", + "version": "3.3.2", "description": "", "main": "src/index.js", "scripts": { From 4000186f1bfcce87763f543b27a49257104b9ac8 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Fri, 8 Oct 2021 13:07:44 +0530 Subject: [PATCH 22/38] addressed linting issue from travis-ci --- specs/apiCall.spec.js | 2 -- specs/apiPort.spec.js | 1 - specs/util.spec.js | 1 - src/apiCall.js | 2 +- src/apiPort.js | 2 +- src/customTypes/faker.js | 3 +-- src/util.js | 2 +- 7 files changed, 4 insertions(+), 9 deletions(-) diff --git a/specs/apiCall.spec.js b/specs/apiCall.spec.js index 0057f81..59204c8 100644 --- a/specs/apiCall.spec.js +++ b/specs/apiCall.spec.js @@ -54,7 +54,6 @@ describe('apiCall', () => { }) }) - it('Should evaluate global fake data', () => { const apiCallConfig = new ApiCall('./fixtures/fixture.spec.yaml', apiPort); const apiCall = first(apiCallConfig.apiCalls.swagger) @@ -65,7 +64,6 @@ describe('apiCall', () => { expect(body.password).not.to.be.a('string') }) - it('Should repeat the file if the repeat tag is present change the it text', () => { const fakeIt = sinon.spy() ApiCall('./fixtures/fixture.repeat.spec.yaml', apiPort, fakeIt) diff --git a/specs/apiPort.spec.js b/specs/apiPort.spec.js index f95b49c..e525bd7 100644 --- a/specs/apiPort.spec.js +++ b/specs/apiPort.spec.js @@ -33,7 +33,6 @@ describe('apiPort', () => { }) }) - describe('set', () => { it('should set a value and be able to get it', () => { const apiPort = new ApiPort() diff --git a/specs/util.spec.js b/specs/util.spec.js index a7e1230..cf52d60 100644 --- a/specs/util.spec.js +++ b/specs/util.spec.js @@ -48,7 +48,6 @@ describe('util', () => { expect(() => util.loadYamlFile('./fixtures/fixture-with-faker-invalid-scope.data.yaml')).to.throw('Error parsing the file ./fixtures/fixture-with-faker-invalid-scope.data.yaml: Error: wrong-scope is not a valid Faker scope. Try one of global,file,test'); }); - it('Should resolve the files and parse yaml into to an object', () => { const data = util.loadYamlFile('./fixtures/fixture.data.yaml') expect(data).to.deep.equal({ diff --git a/src/apiCall.js b/src/apiCall.js index 83ff61b..1929fc5 100644 --- a/src/apiCall.js +++ b/src/apiCall.js @@ -38,7 +38,7 @@ module.exports = function apiCall(file, apiPort, itApi = it) { _.forEach(paths, (actions, route) => { _.forEach(actions, (details, action) => { - operationIds[details.operationId] = Object.assign({}, remainingSpec, { + operationIds[details.operationId] = Object.assign( ...remainingSpec, { paths: { [route]: { [action]: details, diff --git a/src/apiPort.js b/src/apiPort.js index 60cdff8..a2a9e70 100644 --- a/src/apiPort.js +++ b/src/apiPort.js @@ -174,7 +174,7 @@ class ApiPort { } remove() { - this.keys.forEach(key => delete this.apiPort[key]); + this.keys.forEach(key => { delete this.apiPort[key] }); } set(key, value, required = true) { diff --git a/src/customTypes/faker.js b/src/customTypes/faker.js index b664f11..b1a49fd 100644 --- a/src/customTypes/faker.js +++ b/src/customTypes/faker.js @@ -66,7 +66,6 @@ const FakerClassTypeScalar = new YAML.Type('!faker', { represent, }); - const FAKER_SCHEMA = YAML.Schema.create([FakerClassType, FakerClassTypeScalar]) function isFaker(data) { @@ -88,7 +87,7 @@ function evaluateFaker(data, scope) { } if (isObject(data)) { - return mapValues(data, value => (isObject(value) ? evaluateFaker(value, scope) : value)) + return mapValues(data, value => { (isObject(value) ? evaluateFaker(value, scope) : value) }) } return data } diff --git a/src/util.js b/src/util.js index 7738e42..8baac56 100644 --- a/src/util.js +++ b/src/util.js @@ -16,7 +16,7 @@ const { FAKER_SCHEMA } = require('./customTypes/faker.js'); -const isObj = value => isObject(value) && !isFunction(value); +const isObj = value => { isObject(value) && !isFunction(value) } const KEYS_TO_IGNORE = ['before', 'after']; From a9249f866cb904db36814ad41ff56ba43d16215e Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Fri, 8 Oct 2021 13:15:31 +0530 Subject: [PATCH 23/38] addressed linting issue from travis-ci 2 --- specs/faker.spec.js | 2 +- specs/util.spec.js | 2 +- src/apiCall.js | 6 +++--- src/apiPort.js | 4 ++-- src/apiTests.js | 2 +- src/customTypes/faker.js | 2 +- src/mocha.js | 2 +- src/util.js | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/specs/faker.spec.js b/specs/faker.spec.js index dba3dd2..c0a2ff1 100644 --- a/specs/faker.spec.js +++ b/specs/faker.spec.js @@ -1,7 +1,7 @@ const { expect, } = require('chai') -const { FakerClass, fakerScopes } = require('../src/customTypes/faker.js') +const { FakerClass, fakerScopes } = require('../src/customTypes/faker') describe('FakerClass', () => { it('should evaluate faker API', () => { diff --git a/specs/util.spec.js b/specs/util.spec.js index cf52d60..4c08a01 100644 --- a/specs/util.spec.js +++ b/specs/util.spec.js @@ -2,7 +2,7 @@ const { expect, } = require('chai') const path = require('path') -const util = require('../src/util.js') +const util = require('../src/util') describe('util', () => { describe('evaluateData', () => { diff --git a/src/apiCall.js b/src/apiCall.js index 1929fc5..4f5a124 100644 --- a/src/apiCall.js +++ b/src/apiCall.js @@ -4,8 +4,8 @@ const objectPath = require('object-path'); const { expect } = require('chai'); const tryer = require('tryer'); -const { loadYamlFile } = require('./util.js'); -const { evaluateFaker, fakerScopes } = require('./customTypes/faker.js'); +const { loadYamlFile } = require('./util'); +const { evaluateFaker, fakerScopes } = require('./customTypes/faker'); const SuperClient = require('./superClient'); const processedExpectations = ['status', 'json', 'headers', 'error']; @@ -38,7 +38,7 @@ module.exports = function apiCall(file, apiPort, itApi = it) { _.forEach(paths, (actions, route) => { _.forEach(actions, (details, action) => { - operationIds[details.operationId] = Object.assign( ...remainingSpec, { + operationIds[details.operationId] = Object.assign(...remainingSpec, { paths: { [route]: { [action]: details, diff --git a/src/apiPort.js b/src/apiPort.js index a2a9e70..2ad9041 100644 --- a/src/apiPort.js +++ b/src/apiPort.js @@ -5,7 +5,7 @@ const expect = require('expect.js'); const fs = require('fs'); const path = require('path'); const klawSync = require('klaw-sync'); -const { loadFile, YamlParsingError } = require('./util.js'); +const { loadFile, YamlParsingError } = require('./util'); const currentDir = process.cwd(); @@ -174,7 +174,7 @@ class ApiPort { } remove() { - this.keys.forEach(key => { delete this.apiPort[key] }); + this.keys.forEach((key) => delete this.apiPort[key]); } set(key, value, required = true) { diff --git a/src/apiTests.js b/src/apiTests.js index 8fecfe7..0239d52 100644 --- a/src/apiTests.js +++ b/src/apiTests.js @@ -1,4 +1,4 @@ -const { loadYamlFile } = require('./util.js'); +const { loadYamlFile } = require('./util'); module.exports = function tests(file, apiPort) { const config = init(file); diff --git a/src/customTypes/faker.js b/src/customTypes/faker.js index b1a49fd..dc24f80 100644 --- a/src/customTypes/faker.js +++ b/src/customTypes/faker.js @@ -87,7 +87,7 @@ function evaluateFaker(data, scope) { } if (isObject(data)) { - return mapValues(data, value => { (isObject(value) ? evaluateFaker(value, scope) : value) }) + return mapValues(data, (value) => (isObject(value) ? evaluateFaker(value, scope) : value)) } return data } diff --git a/src/mocha.js b/src/mocha.js index b6a4579..60c640a 100644 --- a/src/mocha.js +++ b/src/mocha.js @@ -3,7 +3,7 @@ const klawSync = require('klaw-sync'); const ApiPort = require('./apiPort'); const apiCall = require('./apiCall'); const apiTest = require('./apiTests'); -const { loadYamlFile } = require('./util.js'); +const { loadYamlFile } = require('./util'); const apiPort = new ApiPort(); apiPort.init(); diff --git a/src/util.js b/src/util.js index 8baac56..f581bc8 100644 --- a/src/util.js +++ b/src/util.js @@ -14,9 +14,9 @@ const { evaluateFaker, fakerScopes, FAKER_SCHEMA -} = require('./customTypes/faker.js'); +} = require('./customTypes/faker'); -const isObj = value => { isObject(value) && !isFunction(value) } +const isObj = (value) => (isObject(value) && !isFunction(value)); const KEYS_TO_IGNORE = ['before', 'after']; From daa01962ac720f4818b28a8224c207191c02520a Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Fri, 8 Oct 2021 13:30:33 +0530 Subject: [PATCH 24/38] deleted travis-ci as it's not working --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ba3c005..0000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: node_js -node_js: - - lts/* -script: - - npm run lint - - npm test From e3626e1074fa67b2007b18726e006b30e596b594 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Fri, 8 Oct 2021 13:37:11 +0530 Subject: [PATCH 25/38] deleted travis-ci as it's not working - reverted --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ba3c005 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: node_js +node_js: + - lts/* +script: + - npm run lint + - npm test From 49ac328181618b81ecf76f144622a590779e1cdb Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Mon, 11 Oct 2021 18:22:18 +0530 Subject: [PATCH 26/38] Revert "addressed linting issue from travis-ci" This reverts commit 4000186f --- specs/apiCall.spec.js | 2 ++ specs/apiPort.spec.js | 1 + specs/util.spec.js | 1 + src/apiCall.js | 6 +++--- src/apiPort.js | 4 ++-- src/customTypes/faker.js | 3 ++- src/util.js | 4 ++-- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/specs/apiCall.spec.js b/specs/apiCall.spec.js index 59204c8..0057f81 100644 --- a/specs/apiCall.spec.js +++ b/specs/apiCall.spec.js @@ -54,6 +54,7 @@ describe('apiCall', () => { }) }) + it('Should evaluate global fake data', () => { const apiCallConfig = new ApiCall('./fixtures/fixture.spec.yaml', apiPort); const apiCall = first(apiCallConfig.apiCalls.swagger) @@ -64,6 +65,7 @@ describe('apiCall', () => { expect(body.password).not.to.be.a('string') }) + it('Should repeat the file if the repeat tag is present change the it text', () => { const fakeIt = sinon.spy() ApiCall('./fixtures/fixture.repeat.spec.yaml', apiPort, fakeIt) diff --git a/specs/apiPort.spec.js b/specs/apiPort.spec.js index e525bd7..f95b49c 100644 --- a/specs/apiPort.spec.js +++ b/specs/apiPort.spec.js @@ -33,6 +33,7 @@ describe('apiPort', () => { }) }) + describe('set', () => { it('should set a value and be able to get it', () => { const apiPort = new ApiPort() diff --git a/specs/util.spec.js b/specs/util.spec.js index 4c08a01..5f3de10 100644 --- a/specs/util.spec.js +++ b/specs/util.spec.js @@ -48,6 +48,7 @@ describe('util', () => { expect(() => util.loadYamlFile('./fixtures/fixture-with-faker-invalid-scope.data.yaml')).to.throw('Error parsing the file ./fixtures/fixture-with-faker-invalid-scope.data.yaml: Error: wrong-scope is not a valid Faker scope. Try one of global,file,test'); }); + it('Should resolve the files and parse yaml into to an object', () => { const data = util.loadYamlFile('./fixtures/fixture.data.yaml') expect(data).to.deep.equal({ diff --git a/src/apiCall.js b/src/apiCall.js index 4f5a124..83ff61b 100644 --- a/src/apiCall.js +++ b/src/apiCall.js @@ -4,8 +4,8 @@ const objectPath = require('object-path'); const { expect } = require('chai'); const tryer = require('tryer'); -const { loadYamlFile } = require('./util'); -const { evaluateFaker, fakerScopes } = require('./customTypes/faker'); +const { loadYamlFile } = require('./util.js'); +const { evaluateFaker, fakerScopes } = require('./customTypes/faker.js'); const SuperClient = require('./superClient'); const processedExpectations = ['status', 'json', 'headers', 'error']; @@ -38,7 +38,7 @@ module.exports = function apiCall(file, apiPort, itApi = it) { _.forEach(paths, (actions, route) => { _.forEach(actions, (details, action) => { - operationIds[details.operationId] = Object.assign(...remainingSpec, { + operationIds[details.operationId] = Object.assign({}, remainingSpec, { paths: { [route]: { [action]: details, diff --git a/src/apiPort.js b/src/apiPort.js index 2ad9041..60cdff8 100644 --- a/src/apiPort.js +++ b/src/apiPort.js @@ -5,7 +5,7 @@ const expect = require('expect.js'); const fs = require('fs'); const path = require('path'); const klawSync = require('klaw-sync'); -const { loadFile, YamlParsingError } = require('./util'); +const { loadFile, YamlParsingError } = require('./util.js'); const currentDir = process.cwd(); @@ -174,7 +174,7 @@ class ApiPort { } remove() { - this.keys.forEach((key) => delete this.apiPort[key]); + this.keys.forEach(key => delete this.apiPort[key]); } set(key, value, required = true) { diff --git a/src/customTypes/faker.js b/src/customTypes/faker.js index dc24f80..b664f11 100644 --- a/src/customTypes/faker.js +++ b/src/customTypes/faker.js @@ -66,6 +66,7 @@ const FakerClassTypeScalar = new YAML.Type('!faker', { represent, }); + const FAKER_SCHEMA = YAML.Schema.create([FakerClassType, FakerClassTypeScalar]) function isFaker(data) { @@ -87,7 +88,7 @@ function evaluateFaker(data, scope) { } if (isObject(data)) { - return mapValues(data, (value) => (isObject(value) ? evaluateFaker(value, scope) : value)) + return mapValues(data, value => (isObject(value) ? evaluateFaker(value, scope) : value)) } return data } diff --git a/src/util.js b/src/util.js index f581bc8..7738e42 100644 --- a/src/util.js +++ b/src/util.js @@ -14,9 +14,9 @@ const { evaluateFaker, fakerScopes, FAKER_SCHEMA -} = require('./customTypes/faker'); +} = require('./customTypes/faker.js'); -const isObj = (value) => (isObject(value) && !isFunction(value)); +const isObj = value => isObject(value) && !isFunction(value); const KEYS_TO_IGNORE = ['before', 'after']; From 41715872bbe1b07f8edcc3b96201cd87a789bbda Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Mon, 11 Oct 2021 18:26:28 +0530 Subject: [PATCH 27/38] Revert "addressed linting issue from travis-ci 2" This reverts commit a9249f86 --- README.md | 1 - specs/faker.spec.js | 2 +- specs/util.spec.js | 2 +- src/apiCall.js | 6 +++--- src/apiPort.js | 2 +- src/apiTests.js | 2 +- src/customTypes/faker.js | 3 +-- src/mocha.js | 2 +- src/util.js | 2 +- 9 files changed, 10 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1f98e5e..940befc 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,6 @@ Options: -g, --globalConfig [path] Global Test data config folder relative/ absolute path. e.g: /global-config -u, --url [url] Server URL. e.g: http://localhost:9000 -r, --report Will generate the html report or not. Default 0; e.g: 1 or 0 - -i, --inline-report-assets Inline assets in generated HTML report. -p, --proxy [proxy] The Proxy URL, e.g: http://127.0.0.1:8080 -h, --help output usage information ``` diff --git a/specs/faker.spec.js b/specs/faker.spec.js index c0a2ff1..dba3dd2 100644 --- a/specs/faker.spec.js +++ b/specs/faker.spec.js @@ -1,7 +1,7 @@ const { expect, } = require('chai') -const { FakerClass, fakerScopes } = require('../src/customTypes/faker') +const { FakerClass, fakerScopes } = require('../src/customTypes/faker.js') describe('FakerClass', () => { it('should evaluate faker API', () => { diff --git a/specs/util.spec.js b/specs/util.spec.js index 5f3de10..a7e1230 100644 --- a/specs/util.spec.js +++ b/specs/util.spec.js @@ -2,7 +2,7 @@ const { expect, } = require('chai') const path = require('path') -const util = require('../src/util') +const util = require('../src/util.js') describe('util', () => { describe('evaluateData', () => { diff --git a/src/apiCall.js b/src/apiCall.js index 83ff61b..83fa741 100644 --- a/src/apiCall.js +++ b/src/apiCall.js @@ -4,8 +4,8 @@ const objectPath = require('object-path'); const { expect } = require('chai'); const tryer = require('tryer'); -const { loadYamlFile } = require('./util.js'); -const { evaluateFaker, fakerScopes } = require('./customTypes/faker.js'); +const { loadYamlFile } = require('./util'); +const { evaluateFaker, fakerScopes } = require('./customTypes/faker'); const SuperClient = require('./superClient'); const processedExpectations = ['status', 'json', 'headers', 'error']; @@ -38,7 +38,7 @@ module.exports = function apiCall(file, apiPort, itApi = it) { _.forEach(paths, (actions, route) => { _.forEach(actions, (details, action) => { - operationIds[details.operationId] = Object.assign({}, remainingSpec, { + operationIds[details.operationId] = Object.assign( ...remainingSpec, { paths: { [route]: { [action]: details, diff --git a/src/apiPort.js b/src/apiPort.js index 60cdff8..a2a9e70 100644 --- a/src/apiPort.js +++ b/src/apiPort.js @@ -174,7 +174,7 @@ class ApiPort { } remove() { - this.keys.forEach(key => delete this.apiPort[key]); + this.keys.forEach(key => { delete this.apiPort[key] }); } set(key, value, required = true) { diff --git a/src/apiTests.js b/src/apiTests.js index 0239d52..8fecfe7 100644 --- a/src/apiTests.js +++ b/src/apiTests.js @@ -1,4 +1,4 @@ -const { loadYamlFile } = require('./util'); +const { loadYamlFile } = require('./util.js'); module.exports = function tests(file, apiPort) { const config = init(file); diff --git a/src/customTypes/faker.js b/src/customTypes/faker.js index b664f11..b1a49fd 100644 --- a/src/customTypes/faker.js +++ b/src/customTypes/faker.js @@ -66,7 +66,6 @@ const FakerClassTypeScalar = new YAML.Type('!faker', { represent, }); - const FAKER_SCHEMA = YAML.Schema.create([FakerClassType, FakerClassTypeScalar]) function isFaker(data) { @@ -88,7 +87,7 @@ function evaluateFaker(data, scope) { } if (isObject(data)) { - return mapValues(data, value => (isObject(value) ? evaluateFaker(value, scope) : value)) + return mapValues(data, value => { (isObject(value) ? evaluateFaker(value, scope) : value) }) } return data } diff --git a/src/mocha.js b/src/mocha.js index 60c640a..b6a4579 100644 --- a/src/mocha.js +++ b/src/mocha.js @@ -3,7 +3,7 @@ const klawSync = require('klaw-sync'); const ApiPort = require('./apiPort'); const apiCall = require('./apiCall'); const apiTest = require('./apiTests'); -const { loadYamlFile } = require('./util'); +const { loadYamlFile } = require('./util.js'); const apiPort = new ApiPort(); apiPort.init(); diff --git a/src/util.js b/src/util.js index 7738e42..8baac56 100644 --- a/src/util.js +++ b/src/util.js @@ -16,7 +16,7 @@ const { FAKER_SCHEMA } = require('./customTypes/faker.js'); -const isObj = value => isObject(value) && !isFunction(value); +const isObj = value => { isObject(value) && !isFunction(value) } const KEYS_TO_IGNORE = ['before', 'after']; From 50484e4e77e770832092a82dc7b6981992fee09a Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Mon, 11 Oct 2021 18:29:51 +0530 Subject: [PATCH 28/38] reverted linting fix --- src/apiCall.js | 6 +++--- src/apiPort.js | 2 +- src/customTypes/faker.js | 3 ++- src/util.js | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/apiCall.js b/src/apiCall.js index 83fa741..83ff61b 100644 --- a/src/apiCall.js +++ b/src/apiCall.js @@ -4,8 +4,8 @@ const objectPath = require('object-path'); const { expect } = require('chai'); const tryer = require('tryer'); -const { loadYamlFile } = require('./util'); -const { evaluateFaker, fakerScopes } = require('./customTypes/faker'); +const { loadYamlFile } = require('./util.js'); +const { evaluateFaker, fakerScopes } = require('./customTypes/faker.js'); const SuperClient = require('./superClient'); const processedExpectations = ['status', 'json', 'headers', 'error']; @@ -38,7 +38,7 @@ module.exports = function apiCall(file, apiPort, itApi = it) { _.forEach(paths, (actions, route) => { _.forEach(actions, (details, action) => { - operationIds[details.operationId] = Object.assign( ...remainingSpec, { + operationIds[details.operationId] = Object.assign({}, remainingSpec, { paths: { [route]: { [action]: details, diff --git a/src/apiPort.js b/src/apiPort.js index a2a9e70..60cdff8 100644 --- a/src/apiPort.js +++ b/src/apiPort.js @@ -174,7 +174,7 @@ class ApiPort { } remove() { - this.keys.forEach(key => { delete this.apiPort[key] }); + this.keys.forEach(key => delete this.apiPort[key]); } set(key, value, required = true) { diff --git a/src/customTypes/faker.js b/src/customTypes/faker.js index b1a49fd..b664f11 100644 --- a/src/customTypes/faker.js +++ b/src/customTypes/faker.js @@ -66,6 +66,7 @@ const FakerClassTypeScalar = new YAML.Type('!faker', { represent, }); + const FAKER_SCHEMA = YAML.Schema.create([FakerClassType, FakerClassTypeScalar]) function isFaker(data) { @@ -87,7 +88,7 @@ function evaluateFaker(data, scope) { } if (isObject(data)) { - return mapValues(data, value => { (isObject(value) ? evaluateFaker(value, scope) : value) }) + return mapValues(data, value => (isObject(value) ? evaluateFaker(value, scope) : value)) } return data } diff --git a/src/util.js b/src/util.js index 8baac56..7738e42 100644 --- a/src/util.js +++ b/src/util.js @@ -16,7 +16,7 @@ const { FAKER_SCHEMA } = require('./customTypes/faker.js'); -const isObj = value => { isObject(value) && !isFunction(value) } +const isObj = value => isObject(value) && !isFunction(value); const KEYS_TO_IGNORE = ['before', 'after']; From da5e40e599c5fde4621f2816a95fd3db4a28a473 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Mon, 11 Oct 2021 19:20:02 +0530 Subject: [PATCH 29/38] added tags system for test --- bin/openapitest.js | 4 ++++ src/mocha.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/bin/openapitest.js b/bin/openapitest.js index 11182d4..904a4be 100755 --- a/bin/openapitest.js +++ b/bin/openapitest.js @@ -34,6 +34,7 @@ program 'Will generate the html report or not. e.g: 1 or 0', parseInt ) + .option('-a, --tag [tag]', 'Specify tags to run the tests, leave empty to run all') .option('-u, --url [url]', 'Server URL. e.g: http://localhost:9000') .option('-p, --proxy [proxy]', 'Proxy URL. e.g: http://127.0.0.1:8080') @@ -78,6 +79,9 @@ if (program.proxy) { } process.env.API_SERVER_URL = program.url +if (program.tag) { + process.env.TAGS = program.tag +} let options = {} if(program.report) { diff --git a/src/mocha.js b/src/mocha.js index b6a4579..bbcf4a4 100644 --- a/src/mocha.js +++ b/src/mocha.js @@ -8,6 +8,11 @@ const { loadYamlFile } = require('./util.js'); const apiPort = new ApiPort(); apiPort.init(); +let tagsArray = []; +if (process.env.TAGS) { + tagsArray = process.env.TAGS.split(','); +} + if (apiPort.get('API_TESTS_PATH')) { const paths = klawSync(apiPort.get('API_TESTS_PATH'), { nodir: true }); if (paths) { @@ -18,6 +23,34 @@ if (apiPort.get('API_TESTS_PATH')) { apiPort.currentFile = filePath; const config = loadYamlFile(filePath); describe(filePath, () => { + let tagsInTest = []; + if (tagsInTest) { + if (!Array.isArray(config.apiCalls.tag)) { + tagsInTest = [config.apiCalls.tag]; + } else { + tagsInTest = config.apiCalls.tag; + } + } + if (tagsArray.length > 0) { + let tagMatched = false; + for (const tagInArgs of tagsArray) { + for (const tagInTest of tagsInTest) { + if (tagInArgs === tagInTest) { + tagMatched = true; + break; + } + } + if (tagMatched) { + break; + } + } + + if (!tagMatched) { + console.error(`The tags ${config.apiCalls.tag || 'empty'} in file: ${filePath} does not match the expected tags: ${tagsArray || 'empty'}`); + return false; + } + } + const describeMethod = config.only ? describe.only : describe; describeMethod( (config.apiCalls || {}).name || 'unnamed', From 28cf72cc0f9e98d5d62ff8e0af8f83cf2d93f42d Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Mon, 11 Oct 2021 19:23:31 +0530 Subject: [PATCH 30/38] added readme and version change --- README.md | 1 + bin/openapitest.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 940befc..6835cbe 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ Options: -u, --url [url] Server URL. e.g: http://localhost:9000 -r, --report Will generate the html report or not. Default 0; e.g: 1 or 0 -p, --proxy [proxy] The Proxy URL, e.g: http://127.0.0.1:8080 + -a, --tag [tag] Comma seperated tags to run the test, leave empty to run all -h, --help output usage information ``` diff --git a/bin/openapitest.js b/bin/openapitest.js index 904a4be..a94314f 100755 --- a/bin/openapitest.js +++ b/bin/openapitest.js @@ -34,7 +34,7 @@ program 'Will generate the html report or not. e.g: 1 or 0', parseInt ) - .option('-a, --tag [tag]', 'Specify tags to run the tests, leave empty to run all') + .option('-a, --tag [tag]', 'Comma seperated tags to run the test, leave empty to run all') .option('-u, --url [url]', 'Server URL. e.g: http://localhost:9000') .option('-p, --proxy [proxy]', 'Proxy URL. e.g: http://127.0.0.1:8080') diff --git a/package.json b/package.json index 78685f2..2a7e698 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.3.2", + "version": "3.4", "description": "", "main": "src/index.js", "scripts": { From ac766e37a431b5b28b9bf143df033d2688431e8e Mon Sep 17 00:00:00 2001 From: Vinay Sheoran Date: Mon, 11 Oct 2021 22:54:37 +0530 Subject: [PATCH 31/38] Delete .travis.yml --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ba3c005..0000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: node_js -node_js: - - lts/* -script: - - npm run lint - - npm test From 96573380cc72cd3dcb5f87b20f29be5c7e6f2e2b Mon Sep 17 00:00:00 2001 From: Vinay Sheoran Date: Mon, 11 Oct 2021 22:55:12 +0530 Subject: [PATCH 32/38] removed travis badge from readme --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 940befc..ef33b3a 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,6 @@ The purpose of this openapitest framework is to simplify authoring, organizing, executing, and reporting result of API tests using API specification. It runs on node.js and distributed via npm. Add this module to your node.js project as a development dependency and start writing API or Integration tests using YAML language. - -[![Build Status](https://travis-ci.org/testbetter/openapitest.svg?branch=master)](https://travis-ci.org/testbetter/openapitest) - ### Installation ---- ```npm install --save-dev openapitest``` From ba850d54191a47855cd2982593cf59dddcffd39b Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Tue, 12 Oct 2021 19:21:41 +0530 Subject: [PATCH 33/38] added multi-report - junit and mochawesome --- bin/openapitest.js | 26 ++++++++++++++++++-------- package.json | 4 +++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/bin/openapitest.js b/bin/openapitest.js index a94314f..8c8647b 100755 --- a/bin/openapitest.js +++ b/bin/openapitest.js @@ -85,15 +85,25 @@ if (program.tag) { let options = {} if(program.report) { - options.reporter = 'mochawesome' + options.reporter = 'mocha-multi-reporters' options.reporterOptions = { - reportDir: 'reports', - reportFilename: 'test-int-report', - overwrite: true, - charts: true, - code: false, - quiet: true, - inline: true + reporterEnabled: "mocha-junit-reporter, mochawesome", + mochaJunitReporterReporterOptions: { + mochaFile: "reports/junit/results-[hash].xml", + includePending: true, + jenkinsMode: true + }, + mochawesomeReporterOptions: { + reportDir: "reports", + reportFilename: "openapitest-report", + html: false, + json: true, + overwrite: true, + charts: true, + code: false, + quiet: true, + inline: true + } } } diff --git a/package.json b/package.json index 2a7e698..cb536a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.4", + "version": "3.4.2", "description": "", "main": "src/index.js", "scripts": { @@ -43,6 +43,8 @@ "klaw-sync": "^6.0.0", "lodash": "^4.17.21", "mocha": "^8.4.0", + "mocha-junit-reporter": "^2.0.2", + "mocha-multi-reporters": "^1.5.1", "mochawesome": "^6.2.2", "object-path": "^0.11.5", "object-values": "^2.0.0", From 7620d15e9e3e809125001ab6e69b7cbce300811f Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Mon, 18 Oct 2021 18:32:17 +0530 Subject: [PATCH 34/38] changed tags to string --- src/mocha.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mocha.js b/src/mocha.js index bbcf4a4..35fe363 100644 --- a/src/mocha.js +++ b/src/mocha.js @@ -35,7 +35,7 @@ if (apiPort.get('API_TESTS_PATH')) { let tagMatched = false; for (const tagInArgs of tagsArray) { for (const tagInTest of tagsInTest) { - if (tagInArgs === tagInTest) { + if (`${tagInArgs}` === `${tagInTest}`) { tagMatched = true; break; } From c31d3bfa5662fbfafe9fa715bade60fb70d7b2cb Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Mon, 18 Oct 2021 18:32:53 +0530 Subject: [PATCH 35/38] changed version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cb536a7..f265530 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.4.2", + "version": "3.4.3", "description": "", "main": "src/index.js", "scripts": { From 59e02969a6237f18368a6eabf7d96e089172d62f Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Thu, 21 Oct 2021 19:57:59 +0530 Subject: [PATCH 36/38] multi-report enabled HTML --- bin/openapitest.js | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/openapitest.js b/bin/openapitest.js index 8c8647b..6b13ab1 100755 --- a/bin/openapitest.js +++ b/bin/openapitest.js @@ -59,6 +59,8 @@ if (program.dataDir) { process.env.TEST_DATA_PATH = program.testDir } +console.log('#################################################################'); + if (program.sharedir) { checkExists(program.sharedir, 'Common test data directory') process.env.SHARED_TEST_DATA = program.sharedir @@ -96,7 +98,7 @@ if(program.report) { mochawesomeReporterOptions: { reportDir: "reports", reportFilename: "openapitest-report", - html: false, + html: true, json: true, overwrite: true, charts: true, diff --git a/package.json b/package.json index f265530..2b48f34 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.4.3", + "version": "3.4.4", "description": "", "main": "src/index.js", "scripts": { From d98106a8bbec3e5501c63389df44c00fed027332 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Wed, 1 Dec 2021 20:31:12 +0530 Subject: [PATCH 37/38] user can now provide mochaawesome report --- README.md | 1 + bin/openapitest.js | 10 +++++++--- package.json | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b96a152..2f41ee6 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ Options: -r, --report Will generate the html report or not. Default 0; e.g: 1 or 0 -p, --proxy [proxy] The Proxy URL, e.g: http://127.0.0.1:8080 -a, --tag [tag] Comma seperated tags to run the test, leave empty to run all + -m, --reportName [name] The name of mochawesome report file -h, --help output usage information ``` diff --git a/bin/openapitest.js b/bin/openapitest.js index 6b13ab1..749eb48 100755 --- a/bin/openapitest.js +++ b/bin/openapitest.js @@ -37,6 +37,7 @@ program .option('-a, --tag [tag]', 'Comma seperated tags to run the test, leave empty to run all') .option('-u, --url [url]', 'Server URL. e.g: http://localhost:9000') .option('-p, --proxy [proxy]', 'Proxy URL. e.g: http://127.0.0.1:8080') + .option('-m, --reportName [name]', 'The name of mochawesome report file') program.parse(process.argv) @@ -59,8 +60,6 @@ if (program.dataDir) { process.env.TEST_DATA_PATH = program.testDir } -console.log('#################################################################'); - if (program.sharedir) { checkExists(program.sharedir, 'Common test data directory') process.env.SHARED_TEST_DATA = program.sharedir @@ -85,6 +84,11 @@ if (program.tag) { process.env.TAGS = program.tag } +let reportName = "openapitest-report"; +if (program.reportName) { + reportName = program.reportName; +} + let options = {} if(program.report) { options.reporter = 'mocha-multi-reporters' @@ -97,7 +101,7 @@ if(program.report) { }, mochawesomeReporterOptions: { reportDir: "reports", - reportFilename: "openapitest-report", + reportFilename: reportName, html: true, json: true, overwrite: true, diff --git a/package.json b/package.json index 2b48f34..e1f5e35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapitest", - "version": "3.4.4", + "version": "3.4.5", "description": "", "main": "src/index.js", "scripts": { From aa7eb27d9d4cb8e52ed5ebdd3d1fe2d24bbb5237 Mon Sep 17 00:00:00 2001 From: Vinay Kumar Date: Thu, 2 Dec 2021 13:06:52 +0530 Subject: [PATCH 38/38] changed report dir --- bin/openapitest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/openapitest.js b/bin/openapitest.js index 749eb48..492408c 100755 --- a/bin/openapitest.js +++ b/bin/openapitest.js @@ -100,7 +100,7 @@ if(program.report) { jenkinsMode: true }, mochawesomeReporterOptions: { - reportDir: "reports", + reportDir: "reports/mochawesome", reportFilename: reportName, html: true, json: true,