@nx/cypress 18.1.0-beta.2 → 18.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +6 -0
- package/package.json +5 -5
- package/plugins/cypress-preset.js +10 -14
- package/src/generators/component-configuration/component-configuration.js +7 -3
- package/src/generators/component-configuration/files/__directory__/support/component-index.html +4 -1
- package/src/generators/component-configuration/schema.d.ts +1 -0
- package/src/generators/configuration/configuration.js +8 -3
- package/src/generators/cypress-project/cypress-project.js +1 -0
- package/src/generators/init/init.d.ts +1 -0
- package/src/generators/init/init.js +6 -2
- package/src/migrations/update-18-1-0/update-cypress-version-13-6-6.d.ts +2 -0
- package/src/migrations/update-18-1-0/update-cypress-version-13-6-6.js +12 -0
- package/src/utils/config.js +1 -1
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
package/migrations.json
CHANGED
|
@@ -47,6 +47,12 @@
|
|
|
47
47
|
"version": "16.8.0-beta.4",
|
|
48
48
|
"description": "Update to Cypress v13. Most noteable change is video recording is off by default. This migration will only update if the workspace is already on Cypress v12. https://docs.cypress.io/guides/references/migration-guide#Migrating-to-Cypress-130",
|
|
49
49
|
"implementation": "./src/migrations/update-16-8-0/cypress-13"
|
|
50
|
+
},
|
|
51
|
+
"update-cypress-version-13-6-6": {
|
|
52
|
+
"cli": "nx",
|
|
53
|
+
"version": "18.1.0-beta.3",
|
|
54
|
+
"description": "Update to Cypress ^13.6.6 if the workspace is using Cypress v13 to ensure workspaces don't use v13.6.5 which has an issue when verifying Cypress.",
|
|
55
|
+
"implementation": "./src/migrations/update-18-1-0/update-cypress-version-13-6-6"
|
|
50
56
|
}
|
|
51
57
|
},
|
|
52
58
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/cypress",
|
|
3
|
-
"version": "18.1.0-beta.
|
|
3
|
+
"version": "18.1.0-beta.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Cypress contains executors and generators allowing your workspace to use the powerful Cypress integration testing capabilities.",
|
|
6
6
|
"repository": {
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"migrations": "./migrations.json"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nx/devkit": "18.1.0-beta.
|
|
38
|
-
"@nx/eslint": "18.1.0-beta.
|
|
39
|
-
"@nx/js": "18.1.0-beta.
|
|
37
|
+
"@nx/devkit": "18.1.0-beta.4",
|
|
38
|
+
"@nx/eslint": "18.1.0-beta.4",
|
|
39
|
+
"@nx/js": "18.1.0-beta.4",
|
|
40
40
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
41
41
|
"detect-port": "^1.5.1",
|
|
42
42
|
"semver": "^7.5.3",
|
|
43
43
|
"tslib": "^2.3.0",
|
|
44
|
-
"@nrwl/cypress": "18.1.0-beta.
|
|
44
|
+
"@nrwl/cypress": "18.1.0-beta.4"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"cypress": ">= 3 < 14"
|
|
@@ -39,9 +39,14 @@ function startWebServer(webServerCommand) {
|
|
|
39
39
|
stdio: 'inherit',
|
|
40
40
|
});
|
|
41
41
|
return () => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
if (process.platform === 'win32') {
|
|
43
|
+
serverProcess.kill();
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// child.kill() does not work on linux
|
|
47
|
+
// process.kill will kill the whole process group on unix
|
|
48
|
+
process.kill(-serverProcess.pid, 'SIGKILL');
|
|
49
|
+
}
|
|
45
50
|
};
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
@@ -61,21 +66,12 @@ function startWebServer(webServerCommand) {
|
|
|
61
66
|
*/
|
|
62
67
|
function nxE2EPreset(pathToConfig, options) {
|
|
63
68
|
const basePath = options?.cypressDir || 'src';
|
|
64
|
-
const dir = (0, path_1.dirname)(pathToConfig);
|
|
65
|
-
let supportFile = undefined;
|
|
66
|
-
for (const f of ['e2e.ts', 'e2e.js']) {
|
|
67
|
-
const candidate = (0, path_1.join)(dir, basePath, 'support', f);
|
|
68
|
-
if ((0, fs_1.existsSync)(candidate)) {
|
|
69
|
-
supportFile = candidate;
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
69
|
const baseConfig /*Cypress.EndToEndConfigOptions & {
|
|
74
70
|
[NX_PLUGIN_OPTIONS]: unknown;
|
|
75
71
|
}*/ = {
|
|
76
72
|
...nxBaseCypressPreset(pathToConfig),
|
|
77
73
|
fileServerFolder: '.',
|
|
78
|
-
supportFile,
|
|
74
|
+
supportFile: `${basePath}/support/e2e.{js,ts}`,
|
|
79
75
|
specPattern: `${basePath}/**/*.cy.{js,jsx,ts,tsx}`,
|
|
80
76
|
fixturesFolder: `${basePath}/fixtures`,
|
|
81
77
|
[constants_1.NX_PLUGIN_OPTIONS]: {
|
|
@@ -122,7 +118,7 @@ function waitForServer(url, webServerConfig) {
|
|
|
122
118
|
return new Promise((resolve, reject) => {
|
|
123
119
|
let pollTimeout;
|
|
124
120
|
const { protocol } = new URL(url);
|
|
125
|
-
const timeoutDuration = webServerConfig?.timeout ??
|
|
121
|
+
const timeoutDuration = webServerConfig?.timeout ?? 60 * 1000;
|
|
126
122
|
const timeout = setTimeout(() => {
|
|
127
123
|
clearTimeout(pollTimeout);
|
|
128
124
|
reject(new Error(`Web server failed to start in ${timeoutDuration}ms. This can be configured in cypress.config.ts.`));
|
|
@@ -15,7 +15,7 @@ function componentConfigurationGenerator(tree, options) {
|
|
|
15
15
|
exports.componentConfigurationGenerator = componentConfigurationGenerator;
|
|
16
16
|
async function componentConfigurationGeneratorInternal(tree, options) {
|
|
17
17
|
const tasks = [];
|
|
18
|
-
const opts = normalizeOptions(options);
|
|
18
|
+
const opts = normalizeOptions(tree, options);
|
|
19
19
|
tasks.push(await (0, init_1.default)(tree, {
|
|
20
20
|
...opts,
|
|
21
21
|
skipFormat: true,
|
|
@@ -38,14 +38,18 @@ async function componentConfigurationGeneratorInternal(tree, options) {
|
|
|
38
38
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
39
39
|
}
|
|
40
40
|
exports.componentConfigurationGeneratorInternal = componentConfigurationGeneratorInternal;
|
|
41
|
-
function normalizeOptions(options) {
|
|
41
|
+
function normalizeOptions(tree, options) {
|
|
42
42
|
const cyVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
43
43
|
if (cyVersion && cyVersion < 10) {
|
|
44
44
|
throw new Error('Cypress version of 10 or higher is required to use component testing. See the migration guide to upgrade. https://nx.dev/cypress/v11-migration-guide');
|
|
45
45
|
}
|
|
46
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
47
|
+
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
48
|
+
nxJson.useInferencePlugins !== false;
|
|
46
49
|
return {
|
|
47
|
-
addPlugin
|
|
50
|
+
addPlugin,
|
|
48
51
|
...options,
|
|
52
|
+
framework: options.framework ?? null,
|
|
49
53
|
directory: options.directory ?? 'cypress',
|
|
50
54
|
};
|
|
51
55
|
}
|
package/src/generators/component-configuration/files/__directory__/support/component-index.html
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
6
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
7
7
|
<title><%= project %> Components App</title>
|
|
8
|
-
|
|
8
|
+
<% if(framework === 'next') { %>
|
|
9
|
+
<!-- Used by Next.js to inject CSS. -->
|
|
10
|
+
<div id="__next_css__DO_NOT_USE__"></div>
|
|
11
|
+
<% } %>
|
|
9
12
|
</head>
|
|
10
13
|
<body>
|
|
11
14
|
<div data-cy-root></div>
|
|
@@ -20,15 +20,18 @@ function configurationGenerator(tree, options) {
|
|
|
20
20
|
exports.configurationGenerator = configurationGenerator;
|
|
21
21
|
async function configurationGeneratorInternal(tree, options) {
|
|
22
22
|
const opts = normalizeOptions(tree, options);
|
|
23
|
+
opts.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
23
24
|
const tasks = [];
|
|
24
25
|
if (!(0, cypress_version_1.installedCypressVersion)()) {
|
|
25
26
|
tasks.push(await (0, js_1.initGenerator)(tree, { ...options, skipFormat: true }));
|
|
26
27
|
tasks.push(await (0, init_1.default)(tree, {
|
|
27
28
|
...opts,
|
|
28
29
|
skipFormat: true,
|
|
29
|
-
addPlugin: options.addPlugin,
|
|
30
30
|
}));
|
|
31
31
|
}
|
|
32
|
+
else if (opts.addPlugin) {
|
|
33
|
+
(0, init_1.addPlugin)(tree);
|
|
34
|
+
}
|
|
32
35
|
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
33
36
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
34
37
|
const hasPlugin = nxJson.plugins?.some((p) => typeof p === 'string'
|
|
@@ -41,7 +44,6 @@ async function configurationGeneratorInternal(tree, options) {
|
|
|
41
44
|
const linterTask = await (0, add_linter_1.addLinterToCyProject)(tree, {
|
|
42
45
|
...opts,
|
|
43
46
|
cypressDir: opts.directory,
|
|
44
|
-
addPlugin: opts.addPlugin,
|
|
45
47
|
});
|
|
46
48
|
tasks.push(linterTask);
|
|
47
49
|
if (!opts.skipPackageJson) {
|
|
@@ -80,9 +82,12 @@ In this case you need to provide a devServerTarget,'<projectName>:<targetName>[:
|
|
|
80
82
|
if (!options.baseUrl && !devServerTarget) {
|
|
81
83
|
throw new Error('Either baseUrl or devServerTarget must be provided');
|
|
82
84
|
}
|
|
85
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
86
|
+
options.addPlugin ??=
|
|
87
|
+
process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
88
|
+
nxJson.useInferencePlugins !== false;
|
|
83
89
|
return {
|
|
84
90
|
...options,
|
|
85
|
-
addPlugin: options.addPlugin ?? process.env.NX_ADD_PLUGINS !== 'false',
|
|
86
91
|
bundler: options.bundler ?? 'webpack',
|
|
87
92
|
rootProject: options.rootProject ?? projectConfig.root === '.',
|
|
88
93
|
linter: options.linter ?? eslint_1.Linter.EsLint,
|
|
@@ -201,6 +201,7 @@ async function normalizeOptions(host, options) {
|
|
|
201
201
|
});
|
|
202
202
|
options.linter = options.linter || eslint_1.Linter.EsLint;
|
|
203
203
|
options.bundler = options.bundler || 'webpack';
|
|
204
|
+
options.addPlugin ??= process.env.NX_ADD_PLUGINS !== 'false';
|
|
204
205
|
return {
|
|
205
206
|
...options,
|
|
206
207
|
// other generators depend on the rootProject flag down stream
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
2
2
|
import { Schema } from './schema';
|
|
3
|
+
export declare function addPlugin(tree: Tree): void;
|
|
3
4
|
export declare function cypressInitGenerator(tree: Tree, options: Schema): Promise<GeneratorCallback>;
|
|
4
5
|
export declare function cypressInitGeneratorInternal(tree: Tree, options: Schema): Promise<GeneratorCallback>;
|
|
5
6
|
export default cypressInitGenerator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cypressInitGeneratorInternal = exports.cypressInitGenerator = void 0;
|
|
3
|
+
exports.cypressInitGeneratorInternal = exports.cypressInitGenerator = exports.addPlugin = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const update_package_scripts_1 = require("@nx/devkit/src/utils/update-package-scripts");
|
|
6
6
|
const plugin_1 = require("../../plugins/plugin");
|
|
@@ -49,6 +49,7 @@ function addPlugin(tree) {
|
|
|
49
49
|
});
|
|
50
50
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
51
51
|
}
|
|
52
|
+
exports.addPlugin = addPlugin;
|
|
52
53
|
function updateProductionFileset(tree) {
|
|
53
54
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
54
55
|
const productionFileset = nxJson.namedInputs?.production;
|
|
@@ -68,7 +69,10 @@ async function cypressInitGenerator(tree, options) {
|
|
|
68
69
|
exports.cypressInitGenerator = cypressInitGenerator;
|
|
69
70
|
async function cypressInitGeneratorInternal(tree, options) {
|
|
70
71
|
updateProductionFileset(tree);
|
|
71
|
-
|
|
72
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
73
|
+
options.addPlugin ??=
|
|
74
|
+
process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
75
|
+
nxJson.useInferencePlugins !== false;
|
|
72
76
|
if (options.addPlugin) {
|
|
73
77
|
addPlugin(tree);
|
|
74
78
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const cypress_version_1 = require("../../utils/cypress-version");
|
|
5
|
+
async function default_1(tree) {
|
|
6
|
+
if ((0, cypress_version_1.installedCypressVersion)() < 13) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { cypress: '^13.6.6' });
|
|
10
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
11
|
+
}
|
|
12
|
+
exports.default = default_1;
|
package/src/utils/config.js
CHANGED
|
@@ -105,7 +105,7 @@ async function addMountDefinition(cmpCommandFileContents) {
|
|
|
105
105
|
exports.addMountDefinition = addMountDefinition;
|
|
106
106
|
function getProjectCypressConfigPath(tree, projectRoot) {
|
|
107
107
|
const cypressConfigPaths = (0, devkit_1.glob)(tree, [
|
|
108
|
-
|
|
108
|
+
(0, devkit_1.joinPathFragments)(projectRoot, exports.CYPRESS_CONFIG_FILE_NAME_PATTERN),
|
|
109
109
|
]);
|
|
110
110
|
if (cypressConfigPaths.length === 0) {
|
|
111
111
|
throw new Error(`Could not find a cypress config file in ${projectRoot}.`);
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export declare const nxVersion: any;
|
|
|
2
2
|
export declare const eslintPluginCypressVersion = "^2.13.4";
|
|
3
3
|
export declare const typesNodeVersion = "18.16.9";
|
|
4
4
|
export declare const cypressViteDevServerVersion = "^2.2.1";
|
|
5
|
-
export declare const cypressVersion = "^13.
|
|
5
|
+
export declare const cypressVersion = "^13.6.6";
|
|
6
6
|
export declare const cypressWebpackVersion = "^2.0.0";
|
|
7
7
|
export declare const webpackHttpPluginVersion = "^5.5.0";
|
|
8
8
|
export declare const viteVersion = "~5.0.0";
|
package/src/utils/versions.js
CHANGED
|
@@ -5,7 +5,7 @@ exports.nxVersion = require('../../package.json').version;
|
|
|
5
5
|
exports.eslintPluginCypressVersion = '^2.13.4';
|
|
6
6
|
exports.typesNodeVersion = '18.16.9';
|
|
7
7
|
exports.cypressViteDevServerVersion = '^2.2.1';
|
|
8
|
-
exports.cypressVersion = '^13.
|
|
8
|
+
exports.cypressVersion = '^13.6.6';
|
|
9
9
|
exports.cypressWebpackVersion = '^2.0.0';
|
|
10
10
|
exports.webpackHttpPluginVersion = '^5.5.0';
|
|
11
11
|
exports.viteVersion = '~5.0.0';
|