Migrate cypress to v16

This commit is contained in:
Jamie Curnow committed 2026-11-05 07:32:24 +10:00
1 parent 1c76fb76ea
commit ec0f30106d
5 files changed
+38 -9

No files matched your search

+27
View File
@@ -1,5 +1,6 @@
import { plugin as cypressGrepPlugin } from "@cypress/grep/plugin";
import { SwaggerValidation } from "@jc21/cypress-swagger-validation";
import { exec } from "node:child_process";
import chalk from "chalk";
import backendTask from "./backendApi/task.mjs";
@@ -25,6 +26,32 @@ export default (on, config) => {
return null;
},
});
on("task", {
/**
* Replacement for cy.exec(), removed in Cypress 16
*
* @param {object} options
* @param {string} options.command
* @param {bool} [options.failOnNonZeroExit] Defaults to true
* @returns {object} { exitCode, stdout, stderr }
*/
exec({ command, failOnNonZeroExit = true }) {
return new Promise((resolve, reject) => {
exec(command, { maxBuffer: 10 * 1024 * 1024 }, (error, stdout, stderr) => {
const result = {
exitCode: error ? (error.code ?? 1) : 0,
stdout: stdout.trimEnd(),
stderr: stderr.trimEnd(),
};
if (error && failOnNonZeroExit) {
reject(new Error(`Command failed with exit code ${result.exitCode}: ${command}\n${result.stderr}`));
return;
}
resolve(result);
});
});
},
});
on("task", {
getFixturesFolder() {
return config.fixturesFolder;