Skip to content

Commit 316b758

Browse files
committed
Tweaks to cypress suite
1 parent 9b4c349 commit 316b758

File tree

5 files changed

+54
-35
lines changed

5 files changed

+54
-35
lines changed
Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
/// <reference types="cypress" />
22

3-
const SWAGGER_SCHEMA_FILENAME = 'results/swagger-schema.json';
4-
53
describe('Swagger Schema Linting', () => {
64
it('Should be a completely valid schema', () => {
7-
// Save the schema to a file and lint it
8-
cy.request('/api/schema')
9-
.then((response) => {
10-
const fileContent = response.body;
11-
cy.writeFile(SWAGGER_SCHEMA_FILENAME, fileContent);
12-
})
13-
.then(() => {
14-
cy.exec(`yarn swagger-lint '${SWAGGER_SCHEMA_FILENAME}'`)
15-
.then((result) => {
16-
cy.log("Swagger Vacuum Results:\n", result.stdout);
17-
expect(result.code).to.eq(0);
18-
});
19-
});
5+
cy.validateSwaggerFile('/api/schema', 'results/swagger-schema.json');
206
});
217
});

test/cypress/plugins/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { SwaggerValidation } = require('@jc21/cypress-swagger-validation');
2+
const chalk = require('chalk');
23

34
module.exports = (on, config) => {
45
// Replace swaggerBase config var wildcard
@@ -11,7 +12,7 @@ module.exports = (on, config) => {
1112
on('task', require('./backendApi/task')(config));
1213
on('task', {
1314
log(message) {
14-
console.log(message);
15+
console.log(`${chalk.cyan.bold('[')}${chalk.blue.bold('LOG')}${chalk.cyan.bold(']')} ${chalk.red.bold(message)}`);
1516
return null;
1617
}
1718
});

test/cypress/support/commands.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,25 @@ Cypress.Commands.add('randomString', (length) => {
2222
});
2323

2424
/**
25-
* Check the swagger schema:
25+
* Check the swagger schema file:
26+
*
27+
* @param {string} url
28+
* @param {string} savePath
29+
*/
30+
Cypress.Commands.add("validateSwaggerFile", (url, savePath) => {
31+
cy.task('log', `validateSwaggerFile: ${url} -- ${savePath}`)
32+
.then(() => {
33+
return cy
34+
.request(url)
35+
.then((response) => cy.writeFile(savePath, response.body, { log: false }))
36+
.then(() => cy.exec(`yarn swagger-lint '${savePath}'`, { failOnNonZeroExit: false }))
37+
.then((result) => cy.task('log', `Swagger Vacuum Results:\n${result.stdout || ''}`)
38+
.then(() => expect(result.code).to.eq(0)));
39+
});
40+
});
41+
42+
/**
43+
* Check the swagger schema for a specific endpoint:
2644
*
2745
* @param {string} method API Method in swagger doc, "get", "put", "post", "delete"
2846
* @param {integer} code Swagger doc endpoint response code, exactly as defined in swagger doc

test/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"@jc21/cypress-swagger-validation": "^0.3.2",
88
"@quobix/vacuum": "^0.19.4",
99
"axios": "^1.13.1",
10+
"chalk": "^4.1.0",
1011
"cypress": "^14.0.1",
1112
"cypress-multi-reporters": "^2.0.5",
1213
"cypress-wait-until": "^3.0.2",

test/yarn.lock

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,6 @@
247247
resolved "https://registry.yarnpkg.com/@types/sizzle/-/sizzle-2.3.2.tgz#a811b8c18e2babab7d542b3365887ae2e4d9de47"
248248
integrity sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==
249249

250-
"@types/tmp@^0.2.3":
251-
version "0.2.6"
252-
resolved "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.2.6.tgz#d785ee90c52d7cc020e249c948c36f7b32d1e217"
253-
integrity sha512-chhaNf2oKHlRkDGt+tiKE2Z5aJ6qalm7Z9rlLdBwmOiAAf09YQvvoLXjWK4HWPF1xU/fqvMgfNfpVoBscA/tKA==
254-
255250
"@types/yauzl@^2.9.1":
256251
version "2.10.0"
257252
resolved "https://registry.yarnpkg.com/@types/yauzl/-/yauzl-2.10.0.tgz#b3248295276cf8c6f153ebe6a9aba0c988cb2599"
@@ -405,6 +400,11 @@ astral-regex@^2.0.0:
405400
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31"
406401
integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==
407402

403+
async@^3.2.0:
404+
version "3.2.6"
405+
resolved "https://registry.yarnpkg.com/async/-/async-3.2.6.tgz#1b0728e14929d51b85b449b7f06e27c1145e38ce"
406+
integrity sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==
407+
408408
asynckit@^0.4.0:
409409
version "0.4.0"
410410
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
@@ -557,6 +557,11 @@ [email protected]:
557557
resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
558558
integrity sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==
559559

560+
check-more-types@^2.24.0:
561+
version "2.24.0"
562+
resolved "https://registry.yarnpkg.com/check-more-types/-/check-more-types-2.24.0.tgz#1420ffb10fd444dcfc79b43891bbfffd32a84600"
563+
integrity sha512-Pj779qHxV2tuapviy1bSZNEL1maXr13bPYpsvSDB68HlYcYuhlDrmGd63i0JHMCLKzc7rUSNIrpdJlhVlNwrxA==
564+
560565
chokidar@^4.0.1:
561566
version "4.0.3"
562567
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-4.0.3.tgz#7be37a4c03c9aee1ecfe862a4a23b2c70c205d30"
@@ -689,22 +694,22 @@ cypress-wait-until@^3.0.2:
689694
resolved "https://registry.yarnpkg.com/cypress-wait-until/-/cypress-wait-until-3.0.2.tgz#c90dddfa4c46a2c422f5b91d486531c560bae46e"
690695
integrity sha512-iemies796dD5CgjG5kV0MnpEmKSH+s7O83ZoJLVzuVbZmm4lheMsZqAVT73hlMx4QlkwhxbyUzhOBUOZwoOe0w==
691696

692-
cypress@^15.5.0:
693-
version "15.5.0"
694-
resolved "https://registry.yarnpkg.com/cypress/-/cypress-15.5.0.tgz#039c8549f623957a14e57adee46dbfabaabac741"
695-
integrity sha512-7jXBsh5hTfjxr9QQONC2IbdTj0nxSyU8x4eiarMZBzXzCj3pedKviUx8JnLcE4vL8e0TsOzp70WSLRORjEssRA==
697+
cypress@^14.0.1:
698+
version "14.5.4"
699+
resolved "https://registry.yarnpkg.com/cypress/-/cypress-14.5.4.tgz#d821fbb6220c3328e7413acc7724b75319c9e64d"
700+
integrity sha512-0Dhm4qc9VatOcI1GiFGVt8osgpPdqJLHzRwcAB5MSD/CAAts3oybvPUPawHyvJZUd8osADqZe/xzMsZ8sDTjXw==
696701
dependencies:
697702
"@cypress/request" "^3.0.9"
698703
"@cypress/xvfb" "^1.2.4"
699704
"@types/sinonjs__fake-timers" "8.1.1"
700705
"@types/sizzle" "^2.3.2"
701-
"@types/tmp" "^0.2.3"
702706
arch "^2.2.0"
703707
blob-util "^2.0.2"
704708
bluebird "^3.7.2"
705709
buffer "^5.7.1"
706710
cachedir "^2.3.0"
707711
chalk "^4.1.0"
712+
check-more-types "^2.24.0"
708713
ci-info "^4.1.0"
709714
cli-cursor "^3.1.0"
710715
cli-table3 "0.6.1"
@@ -719,8 +724,10 @@ cypress@^15.5.0:
719724
extract-zip "2.0.1"
720725
figures "^3.2.0"
721726
fs-extra "^9.1.0"
727+
getos "^3.2.1"
722728
hasha "5.2.2"
723729
is-installed-globally "~0.4.0"
730+
lazy-ass "^1.6.0"
724731
listr2 "^3.8.3"
725732
lodash "^4.17.21"
726733
log-symbols "^4.0.0"
@@ -732,8 +739,7 @@ cypress@^15.5.0:
732739
request-progress "^3.0.0"
733740
semver "^7.7.1"
734741
supports-color "^8.1.1"
735-
systeminformation "5.27.7"
736-
tmp "~0.2.4"
742+
tmp "~0.2.3"
737743
tree-kill "1.2.2"
738744
untildify "^4.0.0"
739745
yauzl "^2.10.0"
@@ -1279,6 +1285,13 @@ get-stream@^5.0.0, get-stream@^5.1.0:
12791285
dependencies:
12801286
pump "^3.0.0"
12811287

1288+
getos@^3.2.1:
1289+
version "3.2.1"
1290+
resolved "https://registry.yarnpkg.com/getos/-/getos-3.2.1.tgz#0134d1f4e00eb46144c5a9c0ac4dc087cbb27dc5"
1291+
integrity sha512-U56CfOK17OKgTVqozZjUKNdkfEv6jk5WISBJ8SHoagjE6L69zOwl3Z+O8myjY9MEW3i2HPWQBt/LTbCgcC973Q==
1292+
dependencies:
1293+
async "^3.2.0"
1294+
12821295
getpass@^0.1.1:
12831296
version "0.1.7"
12841297
resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa"
@@ -1582,6 +1595,11 @@ keyv@^4.5.4:
15821595
dependencies:
15831596
json-buffer "3.0.1"
15841597

1598+
lazy-ass@^1.6.0:
1599+
version "1.6.0"
1600+
resolved "https://registry.yarnpkg.com/lazy-ass/-/lazy-ass-1.6.0.tgz#7999655e8646c17f089fdd187d150d3324d54513"
1601+
integrity sha512-cc8oEVoctTvsFZ/Oje/kGnHbpWHYBe8IAJe4C0QNc3t8uM/0Y8+erSz/7Y1ALuXTEZTMvxXwO6YbX1ey3ujiZw==
1602+
15851603
levn@^0.4.1:
15861604
version "0.4.1"
15871605
resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade"
@@ -2281,11 +2299,6 @@ supports-color@^8.1.1:
22812299
dependencies:
22822300
has-flag "^4.0.0"
22832301

2284-
2285-
version "5.27.7"
2286-
resolved "https://registry.yarnpkg.com/systeminformation/-/systeminformation-5.27.7.tgz#4dc9d436419948cd5e5f076779a1298220d19a72"
2287-
integrity sha512-saaqOoVEEFaux4v0K8Q7caiauRwjXC4XbD2eH60dxHXbpKxQ8kH9Rf7Jh+nryKpOUSEFxtCdBlSUx0/lO6rwRg==
2288-
22892302
tar@^6.1.11:
22902303
version "6.2.1"
22912304
resolved "https://registry.yarnpkg.com/tar/-/tar-6.2.1.tgz#717549c541bc3c2af15751bea94b1dd068d4b03a"
@@ -2320,7 +2333,7 @@ tldts@^6.1.32:
23202333
dependencies:
23212334
tldts-core "^6.1.86"
23222335

2323-
tmp@~0.2.4:
2336+
tmp@~0.2.3:
23242337
version "0.2.5"
23252338
resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.5.tgz#b06bcd23f0f3c8357b426891726d16015abfd8f8"
23262339
integrity sha512-voyz6MApa1rQGUxT3E+BK7/ROe8itEx7vD8/HEvt4xwXucvQ5G5oeEiHkmHZJuBO21RpOf+YYm9MOivj709jow==

0 commit comments

Comments
 (0)