Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Commit 7156946

Browse files
committed
[cypress] Fix tests for Cypress 12.17.4 (Webpack 5)
1 parent 6261a76 commit 7156946

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

packages/cypress-plugin/test/integration-input-manual/cypress-config.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import webpackConfig from "./config/webpack.js";
66
import { registerSimpleGitMock } from "unflakable-test-common/dist/git.js";
77
import { registerCosmiconfigMock } from "unflakable-test-common/dist/config.js";
88
import { registerUnflakable } from "@unflakable/cypress-plugin";
9+
import semverGte from "semver/functions/gte.js";
10+
import path from "path";
911

1012
/**
1113
* @type {Cypress.ConfigOptions}
@@ -43,6 +45,14 @@ export default {
4345
tasks.registerTasks(on);
4446
devtools.openDevToolsOnLaunch(on);
4547

48+
// Versions prior to 12.17.4 use Webpack 4, which doesn't support the package.json "exports"
49+
// field (see https://github.com/cypress-io/cypress/issues/23826). Webpack 5 both supports and
50+
// enforces this field, so we have to use a different require path to manually import the
51+
// skip-tests module.
52+
if (semverGte(config.version, "12.17.4")) {
53+
config.supportFile = path.resolve("./cypress/support/e2e-webpack5.js");
54+
}
55+
4656
return registerUnflakable(on, config);
4757
},
4858
// supportFile: "cypress/support/e2e.js",

packages/cypress-plugin/test/integration-input-manual/cypress.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ const { registerSimpleGitMock } = require("unflakable-test-common/dist/git");
77
const {
88
registerCosmiconfigMock,
99
} = require("unflakable-test-common/dist/config");
10+
const semverGte = require("semver/functions/gte");
1011

1112
const { registerUnflakable } = require("@unflakable/cypress-plugin");
13+
const path = require("path");
1214

1315
module.exports = {
1416
/**
@@ -46,6 +48,14 @@ module.exports = {
4648
registerTasks(on);
4749
openDevToolsOnLaunch(on);
4850

51+
// Versions prior to 12.17.4 use Webpack 4, which doesn't support the package.json "exports"
52+
// field (see https://github.com/cypress-io/cypress/issues/23826). Webpack 5 both supports and
53+
// enforces this field, so we have to use a different require path to manually import the
54+
// skip-tests module.
55+
if (semverGte(config.version, "12.17.4")) {
56+
config.supportFile = path.resolve("./cypress/support/e2e-webpack5.js");
57+
}
58+
4959
return registerUnflakable(on, config);
5060
},
5161
// supportFile: "cypress/support/e2e.js",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (c) 2023 Developer Innovations, LLC
2+
3+
// Import commands.js using CJS syntax:
4+
require("./commands.js");
5+
6+
const {
7+
registerMochaInstrumentation,
8+
} = require("@unflakable/cypress-plugin/skip-tests");
9+
10+
registerMochaInstrumentation();

packages/cypress-plugin/test/integration-input-manual/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"process": "^0.11.10",
1717
"react": "^18.2.0",
1818
"react-dom": "^18.2.0",
19+
"semver": "^7.5.4",
1920
"ts-loader": "^9.4.3",
2021
"typescript": "^4.9.5",
2122
"unflakable-test-common": "workspace:^",

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4777,6 +4777,7 @@ __metadata:
47774777
process: ^0.11.10
47784778
react: ^18.2.0
47794779
react-dom: ^18.2.0
4780+
semver: ^7.5.4
47804781
ts-loader: ^9.4.3
47814782
typescript: ^4.9.5
47824783
unflakable-test-common: "workspace:^"

0 commit comments

Comments
 (0)