From 4af0a968f0a83873eb1aed396508d13f728118e5 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Tue, 27 Jan 2026 08:45:23 +1000 Subject: [PATCH] Cypress module conversion and updated chalk --- test/cypress/config/ci.js | 22 ------------------- test/cypress/config/ci.mjs | 23 ++++++++++++++++++++ test/cypress/config/dev.js | 22 ------------------- test/cypress/config/dev.mjs | 23 ++++++++++++++++++++ test/cypress/plugins/{index.js => index.mjs} | 6 ++--- test/jsconfig.json | 5 ++++- test/package.json | 8 +++---- test/yarn.lock | 5 +++++ 8 files changed, 62 insertions(+), 52 deletions(-) delete mode 100644 test/cypress/config/ci.js create mode 100644 test/cypress/config/ci.mjs delete mode 100644 test/cypress/config/dev.js create mode 100644 test/cypress/config/dev.mjs rename test/cypress/plugins/{index.js => index.mjs} (77%) diff --git a/test/cypress/config/ci.js b/test/cypress/config/ci.js deleted file mode 100644 index dc968dbd..00000000 --- a/test/cypress/config/ci.js +++ /dev/null @@ -1,22 +0,0 @@ -const { defineConfig } = require('cypress'); - -module.exports = defineConfig({ - requestTimeout: 30000, - defaultCommandTimeout: 20000, - reporter: 'cypress-multi-reporters', - reporterOptions: { - configFile: 'multi-reporter.json' - }, - video: true, - videosFolder: 'results/videos', - screenshotsFolder: 'results/screenshots', - e2e: { - setupNodeEvents(on, config) { - return require("../plugins/index.js")(on, config); - }, - env: { - swaggerBase: '{{baseUrl}}/api/schema?ts=' + Date.now(), - }, - baseUrl: 'http://fullstack:81', - } -}); diff --git a/test/cypress/config/ci.mjs b/test/cypress/config/ci.mjs new file mode 100644 index 00000000..2597c194 --- /dev/null +++ b/test/cypress/config/ci.mjs @@ -0,0 +1,23 @@ +import { defineConfig } from 'cypress'; +import pluginSetup from '../plugins/index.mjs'; + +export default defineConfig({ + requestTimeout: 30000, + defaultCommandTimeout: 20000, + reporter: "cypress-multi-reporters", + reporterOptions: { + configFile: "multi-reporter.json" + }, + video: true, + videosFolder: "results/videos", + screenshotsFolder: "results/screenshots", + e2e: { + setupNodeEvents(on, config) { + return pluginSetup(on, config); + }, + env: { + swaggerBase: `{{baseUrl}}/api/schema?ts=${Date.now()}`, + }, + baseUrl: "http://fullstack:81", + } +}); diff --git a/test/cypress/config/dev.js b/test/cypress/config/dev.js deleted file mode 100644 index e2f7b6f9..00000000 --- a/test/cypress/config/dev.js +++ /dev/null @@ -1,22 +0,0 @@ -const { defineConfig } = require('cypress'); - -module.exports = defineConfig({ - requestTimeout: 30000, - defaultCommandTimeout: 20000, - reporter: 'cypress-multi-reporters', - reporterOptions: { - configFile: 'multi-reporter.json' - }, - video: true, - videosFolder: 'results/videos', - screenshotsFolder: 'results/screenshots', - e2e: { - setupNodeEvents(on, config) { - return require("../plugins/index.js")(on, config); - }, - env: { - swaggerBase: '{{baseUrl}}/api/schema?ts=' + Date.now(), - }, - baseUrl: 'http://127.0.0.1:3081', - } -}); diff --git a/test/cypress/config/dev.mjs b/test/cypress/config/dev.mjs new file mode 100644 index 00000000..f32d973c --- /dev/null +++ b/test/cypress/config/dev.mjs @@ -0,0 +1,23 @@ +import { defineConfig } from 'cypress'; +import pluginSetup from '../plugins/index.mjs'; + +export default defineConfig({ + requestTimeout: 30000, + defaultCommandTimeout: 20000, + reporter: "cypress-multi-reporters", + reporterOptions: { + configFile: "multi-reporter.json" + }, + video: true, + videosFolder: "results/videos", + screenshotsFolder: "results/screenshots", + e2e: { + setupNodeEvents(on, config) { + return pluginSetup(on, config); + }, + env: { + swaggerBase: `{{baseUrl}}/api/schema?ts=${Date.now()}`, + }, + baseUrl: "http://127.0.0.1:3081", + } +}); diff --git a/test/cypress/plugins/index.js b/test/cypress/plugins/index.mjs similarity index 77% rename from test/cypress/plugins/index.js rename to test/cypress/plugins/index.mjs index 19dd3e17..bf3752b1 100644 --- a/test/cypress/plugins/index.js +++ b/test/cypress/plugins/index.mjs @@ -1,7 +1,7 @@ -const { SwaggerValidation } = require('@jc21/cypress-swagger-validation'); -const chalk = require('chalk'); +import { SwaggerValidation } from '@jc21/cypress-swagger-validation'; +import chalk from 'chalk'; -module.exports = (on, config) => { +export default (on, config) => { // Replace swaggerBase config var wildcard if (typeof config.env.swaggerBase !== 'undefined') { config.env.swaggerBase = config.env.swaggerBase.replace('{{baseUrl}}', config.baseUrl); diff --git a/test/jsconfig.json b/test/jsconfig.json index e7ebe302..ffe33671 100644 --- a/test/jsconfig.json +++ b/test/jsconfig.json @@ -1,6 +1,9 @@ { "include": [ "./node_modules/cypress", - "cypress/**/*.js" + "cypress/**/*.js", + "cypress/config/dev.mjs", + "cypress/config/ci.mjs", + "cypress/plugins/index.mjs" ] } diff --git a/test/package.json b/test/package.json index c3686311..5348baca 100644 --- a/test/package.json +++ b/test/package.json @@ -7,7 +7,7 @@ "@jc21/cypress-swagger-validation": "^0.3.2", "@quobix/vacuum": "^0.19.4", "axios": "^1.13.1", - "chalk": "^4.1.0", + "chalk": "^5.6.2", "cypress": "^15.9.0", "cypress-multi-reporters": "^2.0.5", "cypress-wait-until": "^3.0.2", @@ -21,9 +21,9 @@ "mocha-junit-reporter": "^2.2.1" }, "scripts": { - "cypress": "HTTP_PROXY=127.0.0.1:8128 HTTPS_PROXY=127.0.0.1:8128 cypress open --config-file=cypress/config/ci.js", - "cypress:headless": "HTTP_PROXY=127.0.0.1:8128 HTTPS_PROXY=127.0.0.1:8128 cypress run --config-file=cypress/config/ci.js", - "cypress:dev": "cypress run --config-file=cypress/config/dev.js", + "cypress": "HTTP_PROXY=127.0.0.1:8128 HTTPS_PROXY=127.0.0.1:8128 cypress open --config-file=cypress/config/ci.mjs", + "cypress:headless": "HTTP_PROXY=127.0.0.1:8128 HTTPS_PROXY=127.0.0.1:8128 cypress run --config-file=cypress/config/ci.mjs", + "cypress:dev": "cypress run --config-file=cypress/config/dev.mjs", "swagger-lint": "vacuum lint -b -q -d -a --no-clip -n=warn" }, "author": "", diff --git a/test/yarn.lock b/test/yarn.lock index 38d0adc0..489dd6b2 100644 --- a/test/yarn.lock +++ b/test/yarn.lock @@ -552,6 +552,11 @@ chalk@^4.0.0, chalk@^4.1.0: ansi-styles "^4.1.0" supports-color "^7.1.0" +chalk@^5.6.2: + version "5.6.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.6.2.tgz#b1238b6e23ea337af71c7f8a295db5af0c158aea" + integrity sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA== + charenc@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"