From 9f3a80d9196454bf457ccaa202ea79028e08b2ff Mon Sep 17 00:00:00 2001 From: Igor Savin Date: Wed, 22 Jun 2022 22:32:43 +0300 Subject: [PATCH 1/4] Update dependencies --- .github/workflows/build.yml | 10 +- .gitignore | 2 + package-lock.json | 226 ------------------------------------ package.json | 8 +- src/lib/core.js | 10 +- tests/spec.test.js | 32 ++--- 6 files changed, 32 insertions(+), 256 deletions(-) delete mode 100644 package-lock.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e2501e..b264b40 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,28 +4,28 @@ on: pull_request: paths-ignore: - 'README.md' - branches: + branches: - main push: paths-ignore: - 'README.md' - branches: + branches: - main jobs: build: - + runs-on: ${{ matrix.os }} strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] - node-version: [8.x, 10.x, 12.x, 14.x] + node-version: [8.x, 10.x, 12.x, 14.x, 16.x, 18.x] steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/.gitignore b/.gitignore index b737d8d..d9e683a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ reports/ .vscode *.tar.gz *.tgz +/.idea/ +/package-lock.json diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index ece14f8..0000000 --- a/package-lock.json +++ /dev/null @@ -1,226 +0,0 @@ -{ - "name": "pactum-swagger-coverage", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@arr/every": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@arr/every/-/every-1.0.1.tgz", - "integrity": "sha512-UQFQ6SgyJ6LX42W8rHCs8KVc0JS0tzVL9ct4XYedJukskYVWTo49tNiMEK9C2HTyarbNiT/RVIRSY82vH+6sTg==", - "dev": true - }, - "@exodus/schemasafe": { - "version": "1.0.0-rc.3", - "resolved": "https://registry.npmjs.org/@exodus/schemasafe/-/schemasafe-1.0.0-rc.3.tgz", - "integrity": "sha512-GoXw0U2Qaa33m3eUcxuHnHpNvHjNlLo0gtV091XBpaRINaB4X6FGCG5XKxSFNFiPpugUDqNruHzaqpTdDm4AOg==", - "dev": true - }, - "@polka/url": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@polka/url/-/url-0.5.0.tgz", - "integrity": "sha512-oZLYFEAzUKyi3SKnXvj32ZCEGH6RDnao7COuCVhDydMS9NrCSVXhM79VaKyP5+Zc33m0QXEd2DN3UkU7OsHcfw==", - "dev": true - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true - }, - "centra": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/centra/-/centra-2.4.2.tgz", - "integrity": "sha512-f1RaP0V1HqVNEXfLfjNBthB2yy3KnSGnPCnOPCFLUk9e/Z4rNJ8nBaJNnghflnp88mi1IT8mfmW+HlMS1/H+bg==" - }, - "combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "deep-override": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/deep-override/-/deep-override-1.0.1.tgz", - "integrity": "sha512-ygTX7JJAlk62lMwyf4z3BBeFeUyZudN1t52/xIx1t/4eD0QxOJx2N7+0gDG3g2jjYV1vwznIiFePNFu42kcRdw==", - "dev": true - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true - }, - "dequal": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.2.tgz", - "integrity": "sha512-q9K8BlJVxK7hQYqa6XISGmBZbtQQWVXSrRrWreHC94rMt1QL/Impruc+7p2CYSYuVIUr+YCt6hjrs1kkdJRTug==", - "dev": true - }, - "diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true - }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" - }, - "form-data": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", - "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", - "dev": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - }, - "js-yaml": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", - "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "json-query": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/json-query/-/json-query-2.2.2.tgz", - "integrity": "sha1-tlWLijeUzNIXkmqjgCQyS3e0irE=", - "dev": true - }, - "kleur": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.3.tgz", - "integrity": "sha512-H1tr8QP2PxFTNwAFM74Mui2b6ovcY9FoxJefgrwxY+OCJcq01k5nvhf4M/KnizzrJvLRap5STUy7dgDV35iUBw==", - "dev": true - }, - "matchit": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/matchit/-/matchit-1.1.0.tgz", - "integrity": "sha512-+nGYoOlfHmxe5BW5tE0EMJppXEwdSf8uBA1GTZC7Q77kbT35+VKLYJMzVNWCHSsga1ps1tPYFtFyvxvKzWVmMA==", - "dev": true, - "requires": { - "@arr/every": "^1.0.0" - } - }, - "mime-db": { - "version": "1.44.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", - "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", - "dev": true - }, - "mime-types": { - "version": "2.1.27", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", - "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", - "dev": true, - "requires": { - "mime-db": "1.44.0" - } - }, - "mri": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/mri/-/mri-1.1.6.tgz", - "integrity": "sha512-oi1b3MfbyGa7FJMP9GmLTttni5JoICpYBRlq+x5V16fZbLsnL9N3wFqqIm/nIG43FjUFkFh9Epzp/kzUGUnJxQ==", - "dev": true - }, - "pactum": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/pactum/-/pactum-2.0.10.tgz", - "integrity": "sha512-Qg5T/r5GiimKv0SoohIxc1ER6P9XukSctYCBlBaOKrlfqLLUN9xDmcjFYIJrrbGKlALAlead1Spm3Q4OtZ1fLg==", - "dev": true, - "requires": { - "@exodus/schemasafe": "^1.0.0-rc.2", - "deep-override": "^1.0.1", - "form-data": "^3.0.0", - "json-query": "^2.2.2", - "parse-graphql": "^1.0.0", - "phin": "^3.4.1", - "polka": "^0.5.2" - } - }, - "parse-graphql": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/parse-graphql/-/parse-graphql-1.0.0.tgz", - "integrity": "sha512-NjvQHHaiPCxPZrhm/kKnorxOv7r/eA+tE0VW5E8iJMH9wTqFA1V0YK/7nbpxVu3JdXUxyWTKMez9lsHUtAwa0w==", - "dev": true - }, - "phin": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/phin/-/phin-3.5.0.tgz", - "integrity": "sha512-BEJYqD07B5uBFPAzNpLuLh0LzHr4MDLe0Vc6gBYi+PSIL57VbiE/UvkCc86x24pKQn2X2Keg7HTJEDr8BrBCCg==", - "requires": { - "centra": "^2.4.2" - } - }, - "polka": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/polka/-/polka-0.5.2.tgz", - "integrity": "sha512-FVg3vDmCqP80tOrs+OeNlgXYmFppTXdjD5E7I4ET1NjvtNmQrb1/mJibybKkb/d4NA7YWAr1ojxuhpL3FHqdlw==", - "dev": true, - "requires": { - "@polka/url": "^0.5.0", - "trouter": "^2.0.1" - } - }, - "sade": { - "version": "1.7.4", - "resolved": "https://registry.npmjs.org/sade/-/sade-1.7.4.tgz", - "integrity": "sha512-y5yauMD93rX840MwUJr7C1ysLFBgMspsdTo4UVrDg3fXDvtwOyIqykhVAAm6fk/3au77773itJStObgK+LKaiA==", - "dev": true, - "requires": { - "mri": "^1.1.0" - } - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" - }, - "totalist": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/totalist/-/totalist-2.0.0.tgz", - "integrity": "sha512-+Y17F0YzxfACxTyjfhnJQEe7afPA0GSpYlFkl2VFMxYP7jshQf9gXV7cH47EfToBumFThfKBvfAcoUn6fdNeRQ==", - "dev": true - }, - "trouter": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/trouter/-/trouter-2.0.1.tgz", - "integrity": "sha512-kr8SKKw94OI+xTGOkfsvwZQ8mWoikZDd2n8XZHjJVZUARZT+4/VV6cacRS6CLsH9bNm+HFIPU1Zx4CnNnb4qlQ==", - "dev": true, - "requires": { - "matchit": "^1.0.0" - } - }, - "uvu": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/uvu/-/uvu-0.3.4.tgz", - "integrity": "sha512-UM8M8r+85jYdwn4XII8cjQTojRAkNIaB3kA6FRXX0dQTDAE2NfWs0hLcLJm9/XL1aIFwhSp05vDfDDBlpnZgcg==", - "dev": true, - "requires": { - "dequal": "^2.0.0", - "diff": "^4.0.2", - "kleur": "^4.0.3", - "sade": "^1.7.3", - "totalist": "^2.0.0" - } - } - } -} diff --git a/package.json b/package.json index d4cce0d..f449fcb 100644 --- a/package.json +++ b/package.json @@ -26,12 +26,12 @@ }, "homepage": "https://github.com/leelaprasadv/pactum-swagger-coverage#readme", "devDependencies": { - "pactum": "^2.0.10", - "uvu": "^0.3.4" + "pactum": "^3.0.1", + "uvu": "^0.5.4" }, "dependencies": { - "js-yaml": "^3.14.0", - "phin": "^3.5.0" + "js-yaml": "^4.1.0", + "phin": "^3.6.1" }, "engines": { "node": ">=8" diff --git a/src/lib/core.js b/src/lib/core.js index ee99c93..c66f36a 100644 --- a/src/lib/core.js +++ b/src/lib/core.js @@ -17,7 +17,7 @@ async function loadSwaggerYaml() { try { const swaggerYamlDoc = fs.readFileSync(swaggerYAMLPath, 'utf8'); - return yaml.safeLoad(swaggerYamlDoc); + return yaml.load(swaggerYamlDoc); } catch (err) { throw new PSCSwaggerLoadError(err) } @@ -44,7 +44,7 @@ async function loadSwaggerJson() { /** * Fuction to all get api path's from swagger file - * @param {Object} swaggerInfo + * @param {Object} swaggerInfo * @returns {Array} Array of API paths */ function getApiPaths(swaggerInfo) { @@ -55,7 +55,7 @@ function getApiPaths(swaggerInfo) { /** * Function to get swagger coverage stats - * @param {Array} testsCoveredApis + * @param {Array} testsCoveredApis * @returns {object} Swagger coverage stats */ async function getSwaggerCoverage(testsCoveredApis) { @@ -79,8 +79,8 @@ async function getSwaggerCoverage(testsCoveredApis) { /** * Function to RegEx match api paths - * @param {String} apiPath - * @param {String} rPath + * @param {String} apiPath + * @param {String} rPath * @returns {Boolean} Match result */ function regExMatchOfPath(apiPath, rPath) { diff --git a/tests/spec.test.js b/tests/spec.test.js index 974d30b..0b2225e 100644 --- a/tests/spec.test.js +++ b/tests/spec.test.js @@ -13,47 +13,47 @@ test.before(() => { psc.file = 'report.json' reporter.add(psc); request.setBaseUrl('http://localhost:9393'); - handler.addMockInteractionHandler('get all ninjas', () => { + handler.addInteractionHandler('get all ninjas', () => { return { - withRequest: { + request: { method: 'GET', path: '/api/server/v1/getallninjas' }, - willRespondWith: { + response: { status: 200 } } }); - handler.addMockInteractionHandler('get ninjas by rank', (ctx) => { + handler.addInteractionHandler('get ninjas by rank', (ctx) => { return { - withRequest: { + request: { method: 'GET', path: `/api/server/v1/getninjas/${ctx.data}` }, - willRespondWith: { + response: { status: 200 } } }); - handler.addMockInteractionHandler('get ninja by rank and name', (ctx) => { + handler.addInteractionHandler('get ninja by rank and name', (ctx) => { return { - withRequest: { + request: { method: 'GET', path: `/api/server/v1/getninja/${ctx.data.rank}/${ctx.data.name}` }, - willRespondWith: { + response: { status: 200 } } }); - handler.addMockInteractionHandler('get health', () => { + handler.addInteractionHandler('get health', () => { return { - withRequest: { + request: { method: 'GET', path: `/api/server/v1/health` }, - willRespondWith: { + response: { status: 200 } } @@ -67,28 +67,28 @@ test.after(() => { test('spec passed', async () => { await pactum.spec() - .useMockInteraction('get all ninjas') + .useInteraction('get all ninjas') .get('/api/server/v1/getallninjas') .expectStatus(200); }); test('spec passed - additional path params', async () => { await pactum.spec() - .useMockInteraction('get ninjas by rank', "jounin") + .useInteraction('get ninjas by rank', "jounin") .get('/api/server/v1/getninjas/jounin') .expectStatus(200); }); test('spec passed - no path params', async () => { await pactum.spec() - .useMockInteraction('get health') + .useInteraction('get health') .get('/api/server/v1/health') .expectStatus(200); }); test('spec passed - different api path with path params', async () => { await pactum.spec() - .useMockInteraction('get ninja by rank and name', {rank: "jounin", name: "kakashi"}) + .useInteraction('get ninja by rank and name', {rank: "jounin", name: "kakashi"}) .get('/api/server/v1/getninja/jounin/kakashi') .expectStatus(200); }); From cd6d97beca8f0556d0d7a4a16b34630020344ddc Mon Sep 17 00:00:00 2001 From: Igor Savin Date: Wed, 22 Jun 2022 22:33:28 +0300 Subject: [PATCH 2/4] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f449fcb..8a5fa6b 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ }, "homepage": "https://github.com/leelaprasadv/pactum-swagger-coverage#readme", "devDependencies": { - "pactum": "^3.0.1", + "pactum": "^3.1.10", "uvu": "^0.5.4" }, "dependencies": { From c7681263bd0b65bd755ca1bac988ac754bd6085b Mon Sep 17 00:00:00 2001 From: Anudeep Date: Mon, 11 Jul 2022 14:19:31 +0530 Subject: [PATCH 3/4] bump pactum version to latest --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8a5fa6b..7942ddf 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ }, "homepage": "https://github.com/leelaprasadv/pactum-swagger-coverage#readme", "devDependencies": { - "pactum": "^3.1.10", + "pactum": "^3.1.12", "uvu": "^0.5.4" }, "dependencies": { From 4798a4d1eb5ff3e96e46a99ed6a2e61cf21e8e24 Mon Sep 17 00:00:00 2001 From: Anudeep Date: Mon, 11 Jul 2022 14:20:50 +0530 Subject: [PATCH 4/4] removed version 8 and 10 --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b264b40..d064fe6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] - node-version: [8.x, 10.x, 12.x, 14.x, 16.x, 18.x] + node-version: [12.x, 14.x, 16.x, 18.x] steps: - uses: actions/checkout@v2