@nx/cypress 22.1.0-beta.5 → 22.1.0-beta.7
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 +45 -0
- package/package.json +6 -6
- package/src/executors/cypress/cypress.impl.d.ts +1 -1
- package/src/executors/cypress/cypress.impl.d.ts.map +1 -1
- package/src/executors/cypress/cypress.impl.js +9 -63
- package/src/executors/cypress/schema.json +1 -1
- package/src/generators/component-configuration/component-configuration.d.ts.map +1 -1
- package/src/generators/component-configuration/component-configuration.js +0 -4
- package/src/generators/configuration/configuration.d.ts.map +1 -1
- package/src/generators/configuration/configuration.js +37 -59
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +6 -3
- package/src/migrations/update-22-1-0/rename-cy-exec-code-property.d.ts +3 -0
- package/src/migrations/update-22-1-0/rename-cy-exec-code-property.d.ts.map +1 -0
- package/src/migrations/update-22-1-0/rename-cy-exec-code-property.js +97 -0
- package/src/migrations/update-22-1-0/update-angular-component-testing-support.d.ts +3 -0
- package/src/migrations/update-22-1-0/update-angular-component-testing-support.d.ts.map +1 -0
- package/src/migrations/update-22-1-0/update-angular-component-testing-support.js +123 -0
- package/src/migrations/update-22-1-0/update-selector-playground-api.d.ts +3 -0
- package/src/migrations/update-22-1-0/update-selector-playground-api.d.ts.map +1 -0
- package/src/migrations/update-22-1-0/update-selector-playground-api.js +99 -0
- package/src/utils/add-linter.d.ts.map +1 -1
- package/src/utils/add-linter.js +0 -8
- package/src/utils/cypress-version.d.ts +2 -2
- package/src/utils/cypress-version.js +2 -2
- package/src/utils/versions.d.ts +5 -13
- package/src/utils/versions.d.ts.map +1 -1
- package/src/utils/versions.js +32 -19
- package/src/generators/configuration/files/v9/__directory__/fixtures/example.json__tmpl__ +0 -4
- package/src/generators/configuration/files/v9/__directory__/integration/app.spec.ts__tmpl__ +0 -13
- package/src/generators/configuration/files/v9/__directory__/plugins/index.js__tmpl__ +0 -22
- package/src/generators/configuration/files/v9/__directory__/support/app.po.ts__tmpl__ +0 -1
- package/src/generators/configuration/files/v9/__directory__/support/commands.ts__tmpl__ +0 -33
- package/src/generators/configuration/files/v9/__directory__/support/index.ts__tmpl__ +0 -17
- package/src/generators/configuration/files/v9/__directory__/tsconfig.json +0 -10
- package/src/generators/configuration/files/v9/cypress.json +0 -12
- /package/src/generators/configuration/files/{v10/__directory__ → __directory__}/e2e/app.cy.ts__tmpl__ +0 -0
- /package/src/generators/configuration/files/{v10/__directory__ → __directory__}/support/app.po.ts__tmpl__ +0 -0
- /package/src/generators/configuration/files/{v10/__directory__ → __directory__}/support/e2e.ts__tmpl__ +0 -0
package/migrations.json
CHANGED
|
@@ -40,6 +40,30 @@
|
|
|
40
40
|
"version": "21.0.0-beta.10",
|
|
41
41
|
"description": "Removes the `tsConfig` and `copyFiles` options from the `@nx/cypress:cypress` executor.",
|
|
42
42
|
"implementation": "./src/migrations/update-21-0-0/remove-tsconfig-and-copy-files-options-from-cypress-executor"
|
|
43
|
+
},
|
|
44
|
+
"rename-cy-exec-code-property": {
|
|
45
|
+
"version": "22.1.0-beta.6",
|
|
46
|
+
"requires": {
|
|
47
|
+
"cypress": ">=15.0.0"
|
|
48
|
+
},
|
|
49
|
+
"description": "Renames `cy.exec().its('code')` usages to the new `exitCode` property introduced in Cypress v15.",
|
|
50
|
+
"implementation": "./src/migrations/update-22-1-0/rename-cy-exec-code-property"
|
|
51
|
+
},
|
|
52
|
+
"update-selector-playground-api": {
|
|
53
|
+
"version": "22.1.0-beta.6",
|
|
54
|
+
"requires": {
|
|
55
|
+
"cypress": ">=15.0.0"
|
|
56
|
+
},
|
|
57
|
+
"description": "Updates the deprecated `Cypress.SelectorPlayground` API to `Cypress.ElementSelector` and removes the unsupported `onElement` option.",
|
|
58
|
+
"implementation": "./src/migrations/update-22-1-0/update-selector-playground-api"
|
|
59
|
+
},
|
|
60
|
+
"update-angular-component-testing-support": {
|
|
61
|
+
"version": "22.1.0-beta.6",
|
|
62
|
+
"requires": {
|
|
63
|
+
"cypress": ">=15.0.0"
|
|
64
|
+
},
|
|
65
|
+
"description": "For Angular component testing projects below v18, switches to the fallback `@cypress/angular` harness required by Cypress v15.",
|
|
66
|
+
"implementation": "./src/migrations/update-22-1-0/update-angular-component-testing-support"
|
|
43
67
|
}
|
|
44
68
|
},
|
|
45
69
|
"packageJsonUpdates": {
|
|
@@ -63,6 +87,27 @@
|
|
|
63
87
|
"alwaysAddToPackageJson": false
|
|
64
88
|
}
|
|
65
89
|
}
|
|
90
|
+
},
|
|
91
|
+
"22.1.0": {
|
|
92
|
+
"version": "22.1.0-beta.6",
|
|
93
|
+
"x-prompt": "Do you want to update the Cypress version to v15?",
|
|
94
|
+
"requires": {
|
|
95
|
+
"cypress": ">=14.0.0 <15.0.0"
|
|
96
|
+
},
|
|
97
|
+
"packages": {
|
|
98
|
+
"cypress": {
|
|
99
|
+
"version": "^15.6.0",
|
|
100
|
+
"alwaysAddToPackageJson": false
|
|
101
|
+
},
|
|
102
|
+
"@cypress/vite-dev-server": {
|
|
103
|
+
"version": "^7.0.1",
|
|
104
|
+
"alwaysAddToPackageJson": false
|
|
105
|
+
},
|
|
106
|
+
"@cypress/webpack-dev-server": {
|
|
107
|
+
"version": "^5.1.4",
|
|
108
|
+
"alwaysAddToPackageJson": false
|
|
109
|
+
}
|
|
110
|
+
}
|
|
66
111
|
}
|
|
67
112
|
}
|
|
68
113
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/cypress",
|
|
3
|
-
"version": "22.1.0-beta.
|
|
3
|
+
"version": "22.1.0-beta.7",
|
|
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": {
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"migrations": "./migrations.json"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@nx/devkit": "22.1.0-beta.
|
|
40
|
-
"@nx/eslint": "22.1.0-beta.
|
|
41
|
-
"@nx/js": "22.1.0-beta.
|
|
39
|
+
"@nx/devkit": "22.1.0-beta.7",
|
|
40
|
+
"@nx/eslint": "22.1.0-beta.7",
|
|
41
|
+
"@nx/js": "22.1.0-beta.7",
|
|
42
42
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
43
43
|
"detect-port": "^1.5.1",
|
|
44
44
|
"semver": "^7.6.3",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"tslib": "^2.3.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"nx": "22.1.0-beta.
|
|
49
|
+
"nx": "22.1.0-beta.7"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"cypress": ">=
|
|
52
|
+
"cypress": ">= 13 < 16"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"cypress": {
|
|
@@ -9,7 +9,7 @@ export interface CypressExecutorOptions extends Json {
|
|
|
9
9
|
headed?: boolean;
|
|
10
10
|
/**
|
|
11
11
|
* @deprecated Cypress runs headless by default. Use the --watch flag to
|
|
12
|
-
* control head/headless behavior instead. It will be removed in Nx
|
|
12
|
+
* control head/headless behavior instead. It will be removed in Nx v23.
|
|
13
13
|
**/
|
|
14
14
|
headless?: boolean;
|
|
15
15
|
exit?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cypress.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/executors/cypress/cypress.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"cypress.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/executors/cypress/cypress.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAU,MAAM,YAAY,CAAC;AAQrD,MAAM,MAAM,IAAI,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAAC;AAExC,MAAM,WAAW,sBAAuB,SAAQ,IAAI;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;QAGI;IACJ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;IAC/B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC5C;AAOD,wBAA8B,eAAe,CAC3C,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,eAAe;;GA0BzB"}
|
|
@@ -5,12 +5,10 @@ const devkit_1 = require("@nx/devkit");
|
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const ct_helpers_1 = require("../../utils/ct-helpers");
|
|
8
|
-
const versions_1 = require("../../utils/versions");
|
|
9
8
|
const start_dev_server_1 = require("../../utils/start-dev-server");
|
|
10
9
|
const Cypress = require('cypress'); // @NOTE: Importing via ES6 messes the whole test dependencies.
|
|
11
10
|
async function cypressExecutor(options, context) {
|
|
12
|
-
|
|
13
|
-
options = normalizeOptions(options, context, installedCypressMajorVersion);
|
|
11
|
+
options = normalizeOptions(options, context);
|
|
14
12
|
// this is used by cypress component testing presets to build the executor contexts with the correct configuration options.
|
|
15
13
|
process.env.NX_CYPRESS_TARGET_CONFIGURATION = context.configurationName;
|
|
16
14
|
let success;
|
|
@@ -20,7 +18,7 @@ async function cypressExecutor(options, context) {
|
|
|
20
18
|
success = await runCypress(devServerValues.baseUrl, {
|
|
21
19
|
...options,
|
|
22
20
|
portLockFilePath: devServerValues.portLockFilePath,
|
|
23
|
-
}
|
|
21
|
+
});
|
|
24
22
|
if (!options.watch) {
|
|
25
23
|
generatorInstance.return();
|
|
26
24
|
break;
|
|
@@ -35,70 +33,23 @@ async function cypressExecutor(options, context) {
|
|
|
35
33
|
}
|
|
36
34
|
return { success };
|
|
37
35
|
}
|
|
38
|
-
function normalizeOptions(options, context
|
|
36
|
+
function normalizeOptions(options, context) {
|
|
39
37
|
options.env = options.env || {};
|
|
38
|
+
options.testingType ??= 'e2e';
|
|
40
39
|
if (options.testingType === 'component') {
|
|
41
40
|
const project = context?.projectGraph?.nodes?.[context.projectName];
|
|
42
41
|
if (project?.data?.root) {
|
|
43
42
|
options.ctTailwindPath = (0, ct_helpers_1.getTempTailwindPath)(context);
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
checkSupportedBrowser(options, installedCypressMajorVersion);
|
|
47
|
-
warnDeprecatedHeadless(options, installedCypressMajorVersion);
|
|
48
|
-
warnDeprecatedCypressVersion(installedCypressMajorVersion);
|
|
49
45
|
return options;
|
|
50
46
|
}
|
|
51
|
-
function checkSupportedBrowser({ browser }, installedCypressMajorVersion) {
|
|
52
|
-
// Browser was not passed in as an option, cypress will use whatever default it has set and we dont need to check it
|
|
53
|
-
if (!browser) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (installedCypressMajorVersion >= 4 && browser == 'canary') {
|
|
57
|
-
devkit_1.logger.warn((0, devkit_1.stripIndents) `
|
|
58
|
-
Warning:
|
|
59
|
-
You are using a browser that is not supported by cypress v4+.
|
|
60
|
-
|
|
61
|
-
Read here for more info:
|
|
62
|
-
https://docs.cypress.io/guides/references/migration-guide.html#Launching-Chrome-Canary-with-browser
|
|
63
|
-
`);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const supportedV3Browsers = ['electron', 'chrome', 'canary', 'chromium'];
|
|
67
|
-
if (installedCypressMajorVersion <= 3 &&
|
|
68
|
-
!supportedV3Browsers.includes(browser)) {
|
|
69
|
-
devkit_1.logger.warn((0, devkit_1.stripIndents) `
|
|
70
|
-
Warning:
|
|
71
|
-
You are using a browser that is not supported by cypress v3.
|
|
72
|
-
`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function warnDeprecatedHeadless({ headless }, installedCypressMajorVersion) {
|
|
77
|
-
if (installedCypressMajorVersion < 8 || headless === undefined) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (headless) {
|
|
81
|
-
const deprecatedMsg = (0, devkit_1.stripIndents) `
|
|
82
|
-
NOTE:
|
|
83
|
-
You can now remove the use of the '--headless' flag during 'cypress run' as this is the default for all browsers.`;
|
|
84
|
-
devkit_1.logger.warn(deprecatedMsg);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
function warnDeprecatedCypressVersion(installedCypressMajorVersion) {
|
|
88
|
-
if (installedCypressMajorVersion < 10) {
|
|
89
|
-
devkit_1.logger.warn((0, devkit_1.stripIndents) `
|
|
90
|
-
NOTE:
|
|
91
|
-
Support for Cypress versions < 10 is deprecated. Please upgrade to at least Cypress version 10.
|
|
92
|
-
A generator to migrate from v8 to v10 is provided. See https://nx.dev/cypress/v10-migration-guide
|
|
93
|
-
`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
47
|
/**
|
|
97
48
|
* @whatItDoes Initialize the Cypress test runner with the provided project configuration.
|
|
98
49
|
* By default, Cypress will run tests from the CLI without the GUI and provide directly the results in the console output.
|
|
99
50
|
* If `watch` is `true`: Open Cypress in the interactive GUI to interact directly with the application.
|
|
100
51
|
*/
|
|
101
|
-
async function runCypress(baseUrl, opts
|
|
52
|
+
async function runCypress(baseUrl, opts) {
|
|
102
53
|
// Cypress expects the folder where a cypress config is present
|
|
103
54
|
const projectFolderPath = (0, path_1.dirname)(opts.cypressConfig);
|
|
104
55
|
const options = {
|
|
@@ -134,15 +85,10 @@ async function runCypress(baseUrl, opts, installedCypressMajorVersion) {
|
|
|
134
85
|
options.ciBuildId = opts.ciBuildId?.toString();
|
|
135
86
|
options.group = opts.group;
|
|
136
87
|
// renamed in cy 10
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
options.ignoreTestFiles = opts.ignoreTestFiles;
|
|
145
|
-
}
|
|
88
|
+
options.config ??= {};
|
|
89
|
+
options.config[opts.testingType] = {
|
|
90
|
+
excludeSpecPattern: opts.ignoreTestFiles,
|
|
91
|
+
};
|
|
146
92
|
if (opts.reporter) {
|
|
147
93
|
options.reporter = opts.reporter;
|
|
148
94
|
}
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"type": "boolean",
|
|
45
45
|
"description": "Hide the browser instead of running headed.",
|
|
46
46
|
"default": false,
|
|
47
|
-
"x-deprecated": "Cypress runs headless by default. Use the --watch flag to control head/headless behavior instead. It will be removed in Nx
|
|
47
|
+
"x-deprecated": "Cypress runs headless by default. Use the --watch flag to control head/headless behavior instead. It will be removed in Nx v23."
|
|
48
48
|
},
|
|
49
49
|
"exit": {
|
|
50
50
|
"type": "boolean",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/component-configuration/component-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAGjB,oBAAoB,EAKpB,IAAI,EAIL,MAAM,YAAY,CAAC;AAQpB,OAAO,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAI/D,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,mCAAmC,8BAM7C;AAED,wBAAsB,uCAAuC,CAC3D,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,mCAAmC,8BAwC7C;
|
|
1
|
+
{"version":3,"file":"component-configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/component-configuration/component-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAGjB,oBAAoB,EAKpB,IAAI,EAIL,MAAM,YAAY,CAAC;AAQpB,OAAO,EAAE,mCAAmC,EAAE,MAAM,UAAU,CAAC;AAI/D,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,mCAAmC,8BAM7C;AAED,wBAAsB,uCAAuC,CAC3D,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,mCAAmC,8BAwC7C;AAkHD,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,oBAAoB,QAsDpC;AAOD,eAAe,+BAA+B,CAAC"}
|
|
@@ -42,10 +42,6 @@ async function componentConfigurationGeneratorInternal(tree, options) {
|
|
|
42
42
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
43
43
|
}
|
|
44
44
|
function normalizeOptions(tree, options) {
|
|
45
|
-
const cyVersion = (0, versions_1.getInstalledCypressMajorVersion)(tree);
|
|
46
|
-
if (cyVersion && cyVersion < 10) {
|
|
47
|
-
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');
|
|
48
|
-
}
|
|
49
45
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
50
46
|
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
51
47
|
nxJson.useInferencePlugins !== false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EAWjB,IAAI,EAIL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAsBhD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;IAC/B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAID,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,sBAAsB,8BAMhC;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,sBAAsB,8BA+FhC;
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/configuration/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EAWjB,IAAI,EAIL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAsBhD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;IAC/B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAID,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,sBAAsB,8BAMhC;AAED,wBAAsB,8BAA8B,CAClD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,sBAAsB,8BA+FhC;AA+SD,eAAe,sBAAsB,CAAC"}
|
|
@@ -164,8 +164,6 @@ async function promptForMissingServeData(projectName) {
|
|
|
164
164
|
}
|
|
165
165
|
async function addFiles(tree, options, projectGraph, hasPlugin) {
|
|
166
166
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
167
|
-
const cyVersion = (0, versions_1.getInstalledCypressMajorVersion)(tree);
|
|
168
|
-
const filesToUse = cyVersion && cyVersion < 10 ? 'v9' : 'v10';
|
|
169
167
|
const hasTsConfig = tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'));
|
|
170
168
|
const offsetFromProjectRoot = options.directory
|
|
171
169
|
.split('/')
|
|
@@ -183,76 +181,56 @@ async function addFiles(tree, options, projectGraph, hasPlugin) {
|
|
|
183
181
|
: (0, js_1.getRelativePathToRootTsConfig)(tree, projectConfig.root),
|
|
184
182
|
tmpl: '',
|
|
185
183
|
};
|
|
186
|
-
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
ciBaseUrl = options.ciBaseUrl;
|
|
202
|
-
}
|
|
203
|
-
else if (hasPlugin && options.devServerTarget) {
|
|
204
|
-
webServerCommands = {};
|
|
205
|
-
webServerCommands.default = 'nx run ' + options.devServerTarget;
|
|
206
|
-
const parsedTarget = (0, devkit_1.parseTargetString)(options.devServerTarget, projectGraph);
|
|
207
|
-
const devServerProjectConfig = (0, devkit_1.readProjectConfiguration)(tree, parsedTarget.project);
|
|
208
|
-
// Add production e2e target if serve target is found
|
|
209
|
-
if (parsedTarget.configuration !== 'production' &&
|
|
210
|
-
devServerProjectConfig?.targets?.[parsedTarget.target]
|
|
211
|
-
?.configurations?.['production']) {
|
|
212
|
-
webServerCommands.production = `nx run ${parsedTarget.project}:${parsedTarget.target}:production`;
|
|
213
|
-
}
|
|
214
|
-
// Add ci/static e2e target if serve target is found
|
|
215
|
-
if (devServerProjectConfig?.targets?.['serve-static']) {
|
|
216
|
-
ciWebServerCommand = `nx run ${parsedTarget.project}:serve-static`;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
const updatedCyConfig = await (0, config_1.addDefaultE2EConfig)(tree.read(cyFile, 'utf-8'), {
|
|
220
|
-
cypressDir: options.directory,
|
|
221
|
-
bundler: options.bundler === 'vite' ? 'vite' : undefined,
|
|
222
|
-
webServerCommands,
|
|
223
|
-
ciWebServerCommand: ciWebServerCommand,
|
|
224
|
-
ciBaseUrl,
|
|
225
|
-
}, options.baseUrl);
|
|
226
|
-
tree.write(cyFile, updatedCyConfig);
|
|
227
|
-
}
|
|
228
|
-
if (cyVersion &&
|
|
229
|
-
cyVersion < 7 &&
|
|
230
|
-
tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'src', 'plugins', 'index.js'))) {
|
|
231
|
-
(0, devkit_1.updateJson)(tree, (0, path_1.join)(projectConfig.root, 'cypress.json'), (json) => {
|
|
232
|
-
json.pluginsFile = './src/plugins/index';
|
|
233
|
-
return json;
|
|
234
|
-
});
|
|
184
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), projectConfig.root, fileOpts);
|
|
185
|
+
(0, base_setup_1.addBaseCypressSetup)(tree, {
|
|
186
|
+
project: options.project,
|
|
187
|
+
directory: options.directory,
|
|
188
|
+
jsx: options.jsx,
|
|
189
|
+
js: options.js,
|
|
190
|
+
});
|
|
191
|
+
const cyFile = (0, devkit_1.joinPathFragments)(projectConfig.root, options.js ? 'cypress.config.js' : 'cypress.config.ts');
|
|
192
|
+
let webServerCommands;
|
|
193
|
+
let ciWebServerCommand;
|
|
194
|
+
let ciBaseUrl;
|
|
195
|
+
if (hasPlugin && options.webServerCommands && options.ciWebServerCommand) {
|
|
196
|
+
webServerCommands = options.webServerCommands;
|
|
197
|
+
ciWebServerCommand = options.ciWebServerCommand;
|
|
198
|
+
ciBaseUrl = options.ciBaseUrl;
|
|
235
199
|
}
|
|
236
|
-
else if (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
200
|
+
else if (hasPlugin && options.devServerTarget) {
|
|
201
|
+
webServerCommands = {};
|
|
202
|
+
webServerCommands.default = 'nx run ' + options.devServerTarget;
|
|
203
|
+
const parsedTarget = (0, devkit_1.parseTargetString)(options.devServerTarget, projectGraph);
|
|
204
|
+
const devServerProjectConfig = (0, devkit_1.readProjectConfiguration)(tree, parsedTarget.project);
|
|
205
|
+
// Add production e2e target if serve target is found
|
|
206
|
+
if (parsedTarget.configuration !== 'production' &&
|
|
207
|
+
devServerProjectConfig?.targets?.[parsedTarget.target]?.configurations?.['production']) {
|
|
208
|
+
webServerCommands.production = `nx run ${parsedTarget.project}:${parsedTarget.target}:production`;
|
|
209
|
+
}
|
|
210
|
+
// Add ci/static e2e target if serve target is found
|
|
211
|
+
if (devServerProjectConfig?.targets?.['serve-static']) {
|
|
212
|
+
ciWebServerCommand = `nx run ${parsedTarget.project}:serve-static`;
|
|
240
213
|
}
|
|
241
214
|
}
|
|
215
|
+
const updatedCyConfig = await (0, config_1.addDefaultE2EConfig)(tree.read(cyFile, 'utf-8'), {
|
|
216
|
+
cypressDir: options.directory,
|
|
217
|
+
bundler: options.bundler === 'vite' ? 'vite' : undefined,
|
|
218
|
+
webServerCommands,
|
|
219
|
+
ciWebServerCommand: ciWebServerCommand,
|
|
220
|
+
ciBaseUrl,
|
|
221
|
+
}, options.baseUrl);
|
|
222
|
+
tree.write(cyFile, updatedCyConfig);
|
|
242
223
|
if (options.js) {
|
|
243
224
|
(0, devkit_1.toJS)(tree);
|
|
244
225
|
}
|
|
245
226
|
}
|
|
246
227
|
function addTarget(tree, opts, projectGraph) {
|
|
247
228
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, opts.project);
|
|
248
|
-
const cyVersion = (0, versions_1.getInstalledCypressMajorVersion)(tree);
|
|
249
229
|
projectConfig.targets ??= {};
|
|
250
230
|
projectConfig.targets.e2e = {
|
|
251
231
|
executor: '@nx/cypress:cypress',
|
|
252
232
|
options: {
|
|
253
|
-
cypressConfig: (0, devkit_1.joinPathFragments)(projectConfig.root,
|
|
254
|
-
? 'cypress.json'
|
|
255
|
-
: `cypress.config.${opts.js ? 'js' : 'ts'}`),
|
|
233
|
+
cypressConfig: (0, devkit_1.joinPathFragments)(projectConfig.root, `cypress.config.${opts.js ? 'js' : 'ts'}`),
|
|
256
234
|
testingType: 'e2e',
|
|
257
235
|
},
|
|
258
236
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EACjB,YAAY,EAIZ,IAAI,EAEL,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EACjB,YAAY,EAIZ,IAAI,EAEL,MAAM,YAAY,CAAC;AAQpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AA+ClC,wBAAgB,SAAS,CACvB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,YAAY,EACnB,oBAAoB,EAAE,OAAO,iBAmB9B;AAmBD,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,8BAErE;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,8BA8BhB;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -26,10 +26,13 @@ function setupE2ETargetDefaults(tree) {
|
|
|
26
26
|
function updateDependencies(tree, options) {
|
|
27
27
|
const tasks = [];
|
|
28
28
|
tasks.push((0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@nx/cypress'], []));
|
|
29
|
-
|
|
29
|
+
const devDependencies = {
|
|
30
30
|
['@nx/cypress']: versions_1.nxVersion,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
};
|
|
32
|
+
if (!(0, versions_1.getInstalledCypressVersion)(tree)) {
|
|
33
|
+
devDependencies.cypress = versions_1.cypressVersion;
|
|
34
|
+
}
|
|
35
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDependencies, undefined, options.keepExistingVersions));
|
|
33
36
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
34
37
|
}
|
|
35
38
|
function addPlugin(tree, graph, updatePackageScripts) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-cy-exec-code-property.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/migrations/update-22-1-0/rename-cy-exec-code-property.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAQ1E,wBAA8B,wBAAwB,CAAC,IAAI,EAAE,IAAI,iBAiBhE"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = renameCyExecCodeProperty;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
6
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
|
+
const migrations_1 = require("../../utils/migrations");
|
|
8
|
+
let ts;
|
|
9
|
+
async function renameCyExecCodeProperty(tree) {
|
|
10
|
+
for await (const { projectConfig } of (0, migrations_1.cypressProjectConfigs)(tree)) {
|
|
11
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
|
|
12
|
+
if (!isJsTsFile(filePath) || !tree.exists(filePath)) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const originalContent = tree.read(filePath, 'utf-8');
|
|
16
|
+
const updatedContent = updateCyExecItsCalls(originalContent);
|
|
17
|
+
if (updatedContent !== originalContent) {
|
|
18
|
+
tree.write(filePath, updatedContent);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
23
|
+
}
|
|
24
|
+
function updateCyExecItsCalls(fileContent) {
|
|
25
|
+
// quick check to avoid parsing the file if it doesn't contain the string
|
|
26
|
+
if (!fileContent.includes("its('code')") &&
|
|
27
|
+
!fileContent.includes('its("code")') &&
|
|
28
|
+
!fileContent.includes('its(`code`)')) {
|
|
29
|
+
return fileContent;
|
|
30
|
+
}
|
|
31
|
+
ts ??= (0, ensure_typescript_1.ensureTypescript)();
|
|
32
|
+
const sourceFile = tsquery_1.tsquery.ast(fileContent);
|
|
33
|
+
const updates = [];
|
|
34
|
+
const callExpressions = tsquery_1.tsquery.query(sourceFile, 'CallExpression:has(PropertyAccessExpression > Identifier[name="its"])');
|
|
35
|
+
for (const callExpression of callExpressions) {
|
|
36
|
+
if (!shouldUpdateCallExpression(callExpression)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const firstArg = callExpression.arguments[0];
|
|
40
|
+
const literalText = firstArg.getText(sourceFile);
|
|
41
|
+
const quote = literalText[0];
|
|
42
|
+
const replacementText = `${quote}exitCode${quote}`;
|
|
43
|
+
updates.push({
|
|
44
|
+
start: firstArg.getStart(sourceFile),
|
|
45
|
+
end: firstArg.getEnd(),
|
|
46
|
+
text: replacementText,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
if (!updates.length) {
|
|
50
|
+
return fileContent;
|
|
51
|
+
}
|
|
52
|
+
let updatedContent = fileContent;
|
|
53
|
+
for (const update of updates.sort((a, b) => b.start - a.start)) {
|
|
54
|
+
updatedContent =
|
|
55
|
+
updatedContent.slice(0, update.start) +
|
|
56
|
+
update.text +
|
|
57
|
+
updatedContent.slice(update.end);
|
|
58
|
+
}
|
|
59
|
+
return updatedContent;
|
|
60
|
+
}
|
|
61
|
+
function shouldUpdateCallExpression(node) {
|
|
62
|
+
if (!node.arguments.length) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
ts ??= (0, ensure_typescript_1.ensureTypescript)();
|
|
66
|
+
const firstArg = node.arguments[0];
|
|
67
|
+
if (!(ts.isStringLiteral(firstArg) ||
|
|
68
|
+
ts.isNoSubstitutionTemplateLiteral(firstArg)) ||
|
|
69
|
+
firstArg.text !== 'code') {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
if (!ts.isPropertyAccessExpression(node.expression)) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (node.expression.name.getText() !== 'its') {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
return isDerivedFromCyExec(node.expression.expression);
|
|
79
|
+
}
|
|
80
|
+
function isDerivedFromCyExec(expression) {
|
|
81
|
+
ts ??= (0, ensure_typescript_1.ensureTypescript)();
|
|
82
|
+
if (ts.isCallExpression(expression)) {
|
|
83
|
+
return isDerivedFromCyExec(expression.expression);
|
|
84
|
+
}
|
|
85
|
+
if (ts.isPropertyAccessExpression(expression)) {
|
|
86
|
+
if (expression.name.getText() === 'exec' &&
|
|
87
|
+
ts.isIdentifier(expression.expression) &&
|
|
88
|
+
expression.expression.text === 'cy') {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return isDerivedFromCyExec(expression.expression);
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
function isJsTsFile(filePath) {
|
|
96
|
+
return /\.[cm]?[jt]sx?$/.test(filePath);
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-angular-component-testing-support.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/migrations/update-22-1-0/update-angular-component-testing-support.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAiBpB,wBAA8B,oCAAoC,CAAC,IAAI,EAAE,IAAI,iBAuC5E"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = updateAngularComponentTestingSupport;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
6
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
|
+
const semver_1 = require("semver");
|
|
8
|
+
const config_1 = require("../../utils/config");
|
|
9
|
+
const migrations_1 = require("../../utils/migrations");
|
|
10
|
+
const DEPRECATED_MAX_ANGULAR_VERSION = '18.0.0';
|
|
11
|
+
const CYPRESS_ANGULAR_FALLBACK_VERSION = '^3.0.0';
|
|
12
|
+
let printer;
|
|
13
|
+
let ts;
|
|
14
|
+
async function updateAngularComponentTestingSupport(tree) {
|
|
15
|
+
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
16
|
+
let wereProjectsMigrated = false;
|
|
17
|
+
for await (const { projectConfig, projectName, cypressConfigPath, } of (0, migrations_1.cypressProjectConfigs)(tree)) {
|
|
18
|
+
if (!tree.exists(cypressConfigPath)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const migrationInfo = await getMigrationInfo(tree, cypressConfigPath, projectName, projectGraph);
|
|
22
|
+
if (!migrationInfo) {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
migrateProject(tree, projectConfig);
|
|
26
|
+
wereProjectsMigrated = true;
|
|
27
|
+
}
|
|
28
|
+
if (wereProjectsMigrated) {
|
|
29
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
30
|
+
'@cypress/angular': CYPRESS_ANGULAR_FALLBACK_VERSION,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
34
|
+
}
|
|
35
|
+
async function getMigrationInfo(tree, cypressConfigPath, projectName, projectGraph) {
|
|
36
|
+
ts ??= (0, ensure_typescript_1.ensureTypescript)();
|
|
37
|
+
const cypressConfig = tree.read(cypressConfigPath, 'utf-8');
|
|
38
|
+
const config = (0, config_1.resolveCypressConfigObject)(cypressConfig);
|
|
39
|
+
if (!config) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const component = (0, migrations_1.getObjectProperty)(config, 'component');
|
|
43
|
+
if (!component) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
const framework = resolveFramework(cypressConfig, config, projectName, projectGraph);
|
|
47
|
+
if (framework !== 'angular') {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const angularVersion = resolveAngularVersion(projectName, projectGraph);
|
|
51
|
+
if (!angularVersion || !(0, semver_1.valid)(angularVersion)) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return (0, semver_1.lt)(angularVersion, DEPRECATED_MAX_ANGULAR_VERSION);
|
|
55
|
+
}
|
|
56
|
+
function migrateProject(tree, projectConfig) {
|
|
57
|
+
ts ??= (0, ensure_typescript_1.ensureTypescript)();
|
|
58
|
+
printer ??= ts.createPrinter();
|
|
59
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
|
|
60
|
+
if (!isJsTsFile(filePath) || !tree.exists(filePath)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const originalContent = tree.read(filePath, 'utf-8');
|
|
64
|
+
const sourceFile = tsquery_1.tsquery.ast(originalContent);
|
|
65
|
+
const updatedContent = tsquery_1.tsquery.replace(originalContent, 'ImportDeclaration', (node) => {
|
|
66
|
+
if (!ts.isStringLiteral(node.moduleSpecifier) ||
|
|
67
|
+
node.moduleSpecifier.text !== 'cypress/angular') {
|
|
68
|
+
return node.getText();
|
|
69
|
+
}
|
|
70
|
+
const updatedImport = ts.factory.updateImportDeclaration(node, node.modifiers, node.importClause, ts.factory.createStringLiteral('@cypress/angular'), node.attributes);
|
|
71
|
+
return printer.printNode(ts.EmitHint.Unspecified, updatedImport, sourceFile);
|
|
72
|
+
});
|
|
73
|
+
if (updatedContent !== originalContent) {
|
|
74
|
+
tree.write(filePath, updatedContent);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function resolveFramework(cypressConfig, config, projectName, projectGraph) {
|
|
79
|
+
ts ??= (0, ensure_typescript_1.ensureTypescript)();
|
|
80
|
+
const frameworkProperty = tsquery_1.tsquery.query(config, 'PropertyAssignment:has(Identifier[name=component]) PropertyAssignment:has(Identifier[name=devServer]) PropertyAssignment:has(Identifier[name=framework])')[0];
|
|
81
|
+
if (frameworkProperty) {
|
|
82
|
+
return ts.isStringLiteral(frameworkProperty.initializer)
|
|
83
|
+
? frameworkProperty.initializer.text
|
|
84
|
+
: null;
|
|
85
|
+
}
|
|
86
|
+
const sourceFile = tsquery_1.tsquery.ast(cypressConfig);
|
|
87
|
+
const nxPresetModuleSpecifiers = [
|
|
88
|
+
'@nx/angular/plugins/component-testing',
|
|
89
|
+
'@nx/react/plugins/component-testing',
|
|
90
|
+
'@nx/next/plugins/component-testing',
|
|
91
|
+
'@nx/remix/plugins/component-testing',
|
|
92
|
+
];
|
|
93
|
+
const imports = tsquery_1.tsquery.query(sourceFile, 'ImportDeclaration');
|
|
94
|
+
const nxPresetImport = imports.find((decl) => {
|
|
95
|
+
const moduleSpec = decl.moduleSpecifier.getText().replace(/['"`]/g, '');
|
|
96
|
+
return nxPresetModuleSpecifiers.includes(moduleSpec);
|
|
97
|
+
});
|
|
98
|
+
if (nxPresetImport) {
|
|
99
|
+
const moduleSpecifier = nxPresetImport.moduleSpecifier
|
|
100
|
+
.getText()
|
|
101
|
+
.replace(/['"`]/g, '');
|
|
102
|
+
const plugin = moduleSpecifier.split('/').at(1);
|
|
103
|
+
return plugin === 'angular' ? 'angular' : 'react';
|
|
104
|
+
}
|
|
105
|
+
if (projectGraph.dependencies[projectName]?.some((dependency) => dependency.target.startsWith('npm:@angular/core'))) {
|
|
106
|
+
return 'angular';
|
|
107
|
+
}
|
|
108
|
+
if (projectGraph.dependencies[projectName]?.some((dependency) => dependency.target.startsWith('npm:react') ||
|
|
109
|
+
dependency.target.startsWith('npm:next'))) {
|
|
110
|
+
return 'react';
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
function resolveAngularVersion(projectName, projectGraph) {
|
|
115
|
+
const angularDep = projectGraph.dependencies[projectName]?.find((dependency) => dependency.target.startsWith('npm:@angular/core'));
|
|
116
|
+
if (!angularDep) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return projectGraph.externalNodes?.[angularDep.target]?.data?.version ?? null;
|
|
120
|
+
}
|
|
121
|
+
function isJsTsFile(filePath) {
|
|
122
|
+
return /\.[cm]?[jt]sx?$/.test(filePath);
|
|
123
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-selector-playground-api.d.ts","sourceRoot":"","sources":["../../../../../../packages/cypress/src/migrations/update-22-1-0/update-selector-playground-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAS1E,wBAA8B,2BAA2B,CAAC,IAAI,EAAE,IAAI,iBAiBnE"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = updateSelectorPlaygroundApi;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
6
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
7
|
+
const migrations_1 = require("../../utils/migrations");
|
|
8
|
+
let printer;
|
|
9
|
+
let ts;
|
|
10
|
+
async function updateSelectorPlaygroundApi(tree) {
|
|
11
|
+
for await (const { projectConfig } of (0, migrations_1.cypressProjectConfigs)(tree)) {
|
|
12
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
|
|
13
|
+
if (!isJsTsFile(filePath) || !tree.exists(filePath)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const originalContent = tree.read(filePath, 'utf-8');
|
|
17
|
+
const updatedContent = migrateSelectorPlaygroundApi(originalContent);
|
|
18
|
+
if (updatedContent !== originalContent) {
|
|
19
|
+
tree.write(filePath, updatedContent);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
24
|
+
}
|
|
25
|
+
function migrateSelectorPlaygroundApi(fileContent) {
|
|
26
|
+
let updated = fileContent;
|
|
27
|
+
if (updated.includes('Cypress.SelectorPlayground')) {
|
|
28
|
+
updated = updated.replace(/Cypress\.SelectorPlayground/g, 'Cypress.ElementSelector');
|
|
29
|
+
}
|
|
30
|
+
if (!updated.includes('Cypress.ElementSelector') &&
|
|
31
|
+
!updated.includes('Cypress.SelectorPlayground')) {
|
|
32
|
+
return updated;
|
|
33
|
+
}
|
|
34
|
+
ts ??= (0, ensure_typescript_1.ensureTypescript)();
|
|
35
|
+
printer ??= ts.createPrinter();
|
|
36
|
+
const sourceFile = tsquery_1.tsquery.ast(updated);
|
|
37
|
+
let hasChanges = false;
|
|
38
|
+
const result = tsquery_1.tsquery.replace(updated, 'CallExpression:has(Identifier[name="defaults"])', (node) => {
|
|
39
|
+
if (!ts.isPropertyAccessExpression(node.expression)) {
|
|
40
|
+
return node.getText();
|
|
41
|
+
}
|
|
42
|
+
if (node.expression.name.getText() !== 'defaults') {
|
|
43
|
+
return node.getText();
|
|
44
|
+
}
|
|
45
|
+
const selectorExpr = node.expression.expression;
|
|
46
|
+
if (!ts.isPropertyAccessExpression(selectorExpr)) {
|
|
47
|
+
return node.getText();
|
|
48
|
+
}
|
|
49
|
+
if (!ts.isIdentifier(selectorExpr.expression)) {
|
|
50
|
+
return node.getText();
|
|
51
|
+
}
|
|
52
|
+
if (selectorExpr.expression.text !== 'Cypress') {
|
|
53
|
+
return node.getText();
|
|
54
|
+
}
|
|
55
|
+
const selectorName = selectorExpr.name.getText();
|
|
56
|
+
if (selectorName !== 'ElementSelector' &&
|
|
57
|
+
selectorName !== 'SelectorPlayground') {
|
|
58
|
+
return node.getText();
|
|
59
|
+
}
|
|
60
|
+
if (!node.arguments.length) {
|
|
61
|
+
return node.getText();
|
|
62
|
+
}
|
|
63
|
+
const [firstArg, ...restArgs] = node.arguments;
|
|
64
|
+
if (!ts.isObjectLiteralExpression(firstArg)) {
|
|
65
|
+
return node.getText();
|
|
66
|
+
}
|
|
67
|
+
const filteredProperties = firstArg.properties.filter((prop) => {
|
|
68
|
+
if (ts.isPropertyAssignment(prop) ||
|
|
69
|
+
ts.isShorthandPropertyAssignment(prop) ||
|
|
70
|
+
ts.isMethodDeclaration(prop) ||
|
|
71
|
+
ts.isGetAccessorDeclaration(prop) ||
|
|
72
|
+
ts.isSetAccessorDeclaration(prop)) {
|
|
73
|
+
return !isOnElementProperty(prop.name);
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
});
|
|
77
|
+
if (filteredProperties.length === firstArg.properties.length) {
|
|
78
|
+
return node.getText();
|
|
79
|
+
}
|
|
80
|
+
hasChanges = true;
|
|
81
|
+
const updatedObjectLiteral = ts.factory.updateObjectLiteralExpression(firstArg, filteredProperties);
|
|
82
|
+
const updatedCall = ts.factory.updateCallExpression(node, node.expression, node.typeArguments, [updatedObjectLiteral, ...restArgs]);
|
|
83
|
+
return printer.printNode(ts.EmitHint.Unspecified, updatedCall, sourceFile);
|
|
84
|
+
});
|
|
85
|
+
return hasChanges ? result : updated;
|
|
86
|
+
}
|
|
87
|
+
function isOnElementProperty(name) {
|
|
88
|
+
ts ??= (0, ensure_typescript_1.ensureTypescript)();
|
|
89
|
+
if (ts.isIdentifier(name)) {
|
|
90
|
+
return name.text === 'onElement';
|
|
91
|
+
}
|
|
92
|
+
if (ts.isStringLiteralLike(name)) {
|
|
93
|
+
return name.text === 'onElement';
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
function isJsTsFile(filePath) {
|
|
98
|
+
return /\.[cm]?[jt]sx?$/.test(filePath);
|
|
99
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-linter.d.ts","sourceRoot":"","sources":["../../../../../packages/cypress/src/utils/add-linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,IAAI,EACL,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAwB,MAAM,YAAY,CAAC;AAiBtE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb;;;QAGI;IACJ,UAAU,EAAE,MAAM,CAAC;IACnB;;;QAGI;IACJ,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"add-linter.d.ts","sourceRoot":"","sources":["../../../../../packages/cypress/src/utils/add-linter.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,IAAI,EACL,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAwB,MAAM,YAAY,CAAC;AAiBtE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,EAAE,CAAC,EAAE,OAAO,CAAC;IACb;;;QAGI;IACJ,UAAU,EAAE,MAAM,CAAC;IACnB;;;QAGI;IACJ,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,eAAe,uBA4HzB"}
|
package/src/utils/add-linter.js
CHANGED
|
@@ -53,7 +53,6 @@ async function addLinterToCyProject(tree, options) {
|
|
|
53
53
|
const addExtendsTask = (0, eslint_file_1.addExtendsToLintConfig)(tree, projectConfig.root, 'plugin:cypress/recommended');
|
|
54
54
|
tasks.push(addExtendsTask);
|
|
55
55
|
}
|
|
56
|
-
const cyVersion = (0, versions_1.getInstalledCypressMajorVersion)(tree);
|
|
57
56
|
/**
|
|
58
57
|
* We need this override because we enabled allowJS in the tsconfig to allow for JS based Cypress tests.
|
|
59
58
|
* That however leads to issues with the CommonJS Cypress plugin file.
|
|
@@ -65,7 +64,6 @@ async function addLinterToCyProject(tree, options) {
|
|
|
65
64
|
'no-undef': 'off',
|
|
66
65
|
},
|
|
67
66
|
};
|
|
68
|
-
const addCy6Override = cyVersion && cyVersion < 7;
|
|
69
67
|
if (options.overwriteExisting) {
|
|
70
68
|
overrides.unshift({
|
|
71
69
|
files: (0, flat_config_1.useFlatConfig)(tree)
|
|
@@ -79,9 +77,6 @@ async function addLinterToCyProject(tree, options) {
|
|
|
79
77
|
},
|
|
80
78
|
rules: {},
|
|
81
79
|
});
|
|
82
|
-
if (addCy6Override) {
|
|
83
|
-
overrides.push(cy6Override);
|
|
84
|
-
}
|
|
85
80
|
(0, eslint_file_1.replaceOverridesInLintConfig)(tree, projectConfig.root, overrides);
|
|
86
81
|
}
|
|
87
82
|
else {
|
|
@@ -100,9 +95,6 @@ async function addLinterToCyProject(tree, options) {
|
|
|
100
95
|
},
|
|
101
96
|
rules: {},
|
|
102
97
|
});
|
|
103
|
-
if (addCy6Override) {
|
|
104
|
-
overrides.push(cy6Override);
|
|
105
|
-
}
|
|
106
98
|
overrides.forEach((override) => (0, eslint_file_1.addOverrideToLintConfig)(tree, projectConfig.root, override));
|
|
107
99
|
}
|
|
108
100
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @deprecated use the `getInstalledCypressMajorVersion` exported from
|
|
3
|
-
* `@nx/cypress/src/utils/versions` instead. It will be removed in
|
|
3
|
+
* `@nx/cypress/src/utils/versions` instead. It will be removed in v23.
|
|
4
4
|
*/
|
|
5
5
|
export declare function installedCypressVersion(): number;
|
|
6
6
|
/**
|
|
7
7
|
* will not throw if cypress is not installed
|
|
8
8
|
* @deprecated use the `assertMinimumCypressVersion` exported from
|
|
9
|
-
* `@nx/cypress/src/utils/versions` instead. It will be removed in
|
|
9
|
+
* `@nx/cypress/src/utils/versions` instead. It will be removed in v23.
|
|
10
10
|
*/
|
|
11
11
|
export declare function assertMinimumCypressVersion(minVersion: number): void;
|
|
12
12
|
//# sourceMappingURL=cypress-version.d.ts.map
|
|
@@ -6,7 +6,7 @@ let cypressPackageJson;
|
|
|
6
6
|
let loadedCypress = false;
|
|
7
7
|
/**
|
|
8
8
|
* @deprecated use the `getInstalledCypressMajorVersion` exported from
|
|
9
|
-
* `@nx/cypress/src/utils/versions` instead. It will be removed in
|
|
9
|
+
* `@nx/cypress/src/utils/versions` instead. It will be removed in v23.
|
|
10
10
|
*/
|
|
11
11
|
function installedCypressVersion() {
|
|
12
12
|
if (!loadedCypress) {
|
|
@@ -28,7 +28,7 @@ function installedCypressVersion() {
|
|
|
28
28
|
/**
|
|
29
29
|
* will not throw if cypress is not installed
|
|
30
30
|
* @deprecated use the `assertMinimumCypressVersion` exported from
|
|
31
|
-
* `@nx/cypress/src/utils/versions` instead. It will be removed in
|
|
31
|
+
* `@nx/cypress/src/utils/versions` instead. It will be removed in v23.
|
|
32
32
|
*/
|
|
33
33
|
function assertMinimumCypressVersion(minVersion) {
|
|
34
34
|
const version = installedCypressVersion();
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -2,21 +2,13 @@ import { type Tree } from '@nx/devkit';
|
|
|
2
2
|
export declare const nxVersion: any;
|
|
3
3
|
export declare const eslintPluginCypressVersion = "^3.5.0";
|
|
4
4
|
export declare const typesNodeVersion = "20.19.9";
|
|
5
|
-
export declare const cypressViteDevServerVersion = "^
|
|
6
|
-
export declare const cypressVersion = "^
|
|
7
|
-
export declare const cypressWebpackVersion = "^
|
|
5
|
+
export declare const cypressViteDevServerVersion = "^7.0.1";
|
|
6
|
+
export declare const cypressVersion = "^15.6.0";
|
|
7
|
+
export declare const cypressWebpackVersion = "^5.1.4";
|
|
8
8
|
export declare const viteVersion = "^6.0.0";
|
|
9
9
|
export declare const htmlWebpackPluginVersion = "^5.5.0";
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
eslintPluginCypressVersion: string;
|
|
13
|
-
typesNodeVersion: string;
|
|
14
|
-
cypressViteDevServerVersion: string;
|
|
15
|
-
cypressVersion: string;
|
|
16
|
-
cypressWebpackVersion: string;
|
|
17
|
-
viteVersion: string;
|
|
18
|
-
htmlWebpackPluginVersion: string;
|
|
19
|
-
};
|
|
10
|
+
export type CypressVersions = Record<keyof Omit<typeof import('./versions'), 'nxVersion' | 'versions' | 'getInstalledCypressVersion' | 'getInstalledCypressMajorVersion' | 'assertMinimumCypressVersion'>, string>;
|
|
11
|
+
export declare function versions(tree: Tree): CypressVersions;
|
|
20
12
|
export declare function getInstalledCypressVersion(tree?: Tree): string | null;
|
|
21
13
|
export declare function getInstalledCypressMajorVersion(tree?: Tree): number | null;
|
|
22
14
|
export declare function assertMinimumCypressVersion(minVersion: number, tree?: Tree): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/cypress/src/utils/versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAI5E,eAAO,MAAM,SAAS,KAAwC,CAAC;AAC/D,eAAO,MAAM,0BAA0B,WAAW,CAAC;AACnD,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,2BAA2B,WAAW,CAAC;AACpD,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,wBAAwB,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../../../packages/cypress/src/utils/versions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAI5E,eAAO,MAAM,SAAS,KAAwC,CAAC;AAC/D,eAAO,MAAM,0BAA0B,WAAW,CAAC;AACnD,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,eAAO,MAAM,2BAA2B,WAAW,CAAC;AACpD,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,qBAAqB,WAAW,CAAC;AAC9C,eAAO,MAAM,WAAW,WAAW,CAAC;AACpC,eAAO,MAAM,wBAAwB,WAAW,CAAC;AAEjD,MAAM,MAAM,eAAe,GAAG,MAAM,CAClC,MAAM,IAAI,CACR,cAAc,YAAY,CAAC,EACzB,WAAW,GACX,UAAU,GACV,4BAA4B,GAC5B,iCAAiC,GACjC,6BAA6B,CAChC,EACD,MAAM,CACP,CAAC;AAkCF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,CAmBpD;AAED,wBAAgB,0BAA0B,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAcrE;AAED,wBAAgB,+BAA+B,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAI1E;AAED,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,IAAI,GACV,IAAI,CAON"}
|
package/src/utils/versions.js
CHANGED
|
@@ -10,13 +10,12 @@ const semver_1 = require("semver");
|
|
|
10
10
|
exports.nxVersion = require('../../package.json').version;
|
|
11
11
|
exports.eslintPluginCypressVersion = '^3.5.0';
|
|
12
12
|
exports.typesNodeVersion = '20.19.9';
|
|
13
|
-
exports.cypressViteDevServerVersion = '^
|
|
14
|
-
exports.cypressVersion = '^
|
|
15
|
-
exports.cypressWebpackVersion = '^
|
|
13
|
+
exports.cypressViteDevServerVersion = '^7.0.1';
|
|
14
|
+
exports.cypressVersion = '^15.6.0';
|
|
15
|
+
exports.cypressWebpackVersion = '^5.1.4';
|
|
16
16
|
exports.viteVersion = '^6.0.0';
|
|
17
17
|
exports.htmlWebpackPluginVersion = '^5.5.0';
|
|
18
18
|
const latestVersions = {
|
|
19
|
-
nxVersion: exports.nxVersion,
|
|
20
19
|
eslintPluginCypressVersion: exports.eslintPluginCypressVersion,
|
|
21
20
|
typesNodeVersion: exports.typesNodeVersion,
|
|
22
21
|
cypressViteDevServerVersion: exports.cypressViteDevServerVersion,
|
|
@@ -25,20 +24,8 @@ const latestVersions = {
|
|
|
25
24
|
viteVersion: exports.viteVersion,
|
|
26
25
|
htmlWebpackPluginVersion: exports.htmlWebpackPluginVersion,
|
|
27
26
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (!installedCypressVersion) {
|
|
31
|
-
return latestVersions;
|
|
32
|
-
}
|
|
33
|
-
const cypressMajorVersion = (0, semver_1.major)(installedCypressVersion);
|
|
34
|
-
if (cypressMajorVersion === 14) {
|
|
35
|
-
return latestVersions;
|
|
36
|
-
}
|
|
37
|
-
if (cypressMajorVersion > 14) {
|
|
38
|
-
throw new Error(`You're currently using an unsupported Cypress version: ${installedCypressVersion}. Supported versions are v13 and v14.`);
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
nxVersion: exports.nxVersion,
|
|
27
|
+
const versionMap = {
|
|
28
|
+
13: {
|
|
42
29
|
eslintPluginCypressVersion: '^3.5.0',
|
|
43
30
|
typesNodeVersion: '20.19.9',
|
|
44
31
|
cypressViteDevServerVersion: '^2.2.1',
|
|
@@ -46,7 +33,33 @@ function versions(tree) {
|
|
|
46
33
|
cypressWebpackVersion: '^3.8.0',
|
|
47
34
|
viteVersion: '~5.0.0',
|
|
48
35
|
htmlWebpackPluginVersion: '^5.5.0',
|
|
49
|
-
}
|
|
36
|
+
},
|
|
37
|
+
14: {
|
|
38
|
+
eslintPluginCypressVersion: '^3.5.0',
|
|
39
|
+
typesNodeVersion: '20.19.9',
|
|
40
|
+
cypressViteDevServerVersion: '^6.0.3',
|
|
41
|
+
cypressVersion: '^14.2.1',
|
|
42
|
+
cypressWebpackVersion: '^4.0.2',
|
|
43
|
+
viteVersion: '^6.0.0',
|
|
44
|
+
htmlWebpackPluginVersion: '^5.5.0',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
function versions(tree) {
|
|
48
|
+
const installedCypressVersion = getInstalledCypressVersion(tree);
|
|
49
|
+
if (!installedCypressVersion) {
|
|
50
|
+
return latestVersions;
|
|
51
|
+
}
|
|
52
|
+
const cypressMajorVersion = (0, semver_1.major)(installedCypressVersion);
|
|
53
|
+
switch (cypressMajorVersion) {
|
|
54
|
+
case 15:
|
|
55
|
+
return latestVersions;
|
|
56
|
+
case 14:
|
|
57
|
+
return versionMap[14];
|
|
58
|
+
case 13:
|
|
59
|
+
return versionMap[13];
|
|
60
|
+
default:
|
|
61
|
+
throw new Error(`You're currently using an unsupported Cypress version: ${installedCypressVersion}. Supported versions are v13, v14, and v15.`);
|
|
62
|
+
}
|
|
50
63
|
}
|
|
51
64
|
function getInstalledCypressVersion(tree) {
|
|
52
65
|
try {
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { getGreeting } from '../support/app.po';
|
|
2
|
-
|
|
3
|
-
describe('<%= project %>', () => {
|
|
4
|
-
beforeEach(() => cy.visit('/'));
|
|
5
|
-
|
|
6
|
-
it('should display welcome message', () => {
|
|
7
|
-
// Custom command example, see `../support/commands.ts` file
|
|
8
|
-
cy.login('my-email@something.com', 'myPassword');
|
|
9
|
-
|
|
10
|
-
// Function helper example, see `../support/app.po.ts` file
|
|
11
|
-
getGreeting().contains(/Welcome/);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// ***********************************************************
|
|
2
|
-
// This example plugins/index.js can be used to load plugins
|
|
3
|
-
//
|
|
4
|
-
// You can change the location of this file or turn off loading
|
|
5
|
-
// the plugins file with the 'pluginsFile' configuration option.
|
|
6
|
-
//
|
|
7
|
-
// You can read more here:
|
|
8
|
-
// https://on.cypress.io/plugins-guide
|
|
9
|
-
// ***********************************************************
|
|
10
|
-
|
|
11
|
-
// This function is called when a project is opened or re-opened (e.g. due to
|
|
12
|
-
// the project's config changing)
|
|
13
|
-
|
|
14
|
-
const { preprocessTypescript } = require('@nx/cypress/plugins/preprocessor');
|
|
15
|
-
|
|
16
|
-
module.exports = (on, config) => {
|
|
17
|
-
// `on` is used to hook into various events Cypress emits
|
|
18
|
-
// `config` is the resolved Cypress config
|
|
19
|
-
|
|
20
|
-
// Preprocess Typescript file using Nx helper
|
|
21
|
-
on('file:preprocessor', preprocessTypescript(config));
|
|
22
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const getGreeting = () => cy.get('h1');
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// ***********************************************
|
|
2
|
-
// This example commands.js shows you how to
|
|
3
|
-
// create various custom commands and overwrite
|
|
4
|
-
// existing commands.
|
|
5
|
-
//
|
|
6
|
-
// For more comprehensive examples of custom
|
|
7
|
-
// commands please read more here:
|
|
8
|
-
// https://on.cypress.io/custom-commands
|
|
9
|
-
// ***********************************************
|
|
10
|
-
<% if (linter === 'eslint') { %>
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace<% } %>
|
|
12
|
-
declare namespace Cypress {<% if (linter === 'eslint') { %>
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars<% } %>
|
|
14
|
-
interface Chainable<Subject> {
|
|
15
|
-
login(email: string, password: string): void;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
//
|
|
19
|
-
// -- This is a parent command --
|
|
20
|
-
Cypress.Commands.add('login', (email, password) => {
|
|
21
|
-
console.log('Custom command example: Login', email, password);
|
|
22
|
-
});
|
|
23
|
-
//
|
|
24
|
-
// -- This is a child command --
|
|
25
|
-
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
// -- This is a dual command --
|
|
29
|
-
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
// -- This will overwrite an existing command --
|
|
33
|
-
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// ***********************************************************
|
|
2
|
-
// This example support/index.ts is processed and
|
|
3
|
-
// loaded automatically before your test files.
|
|
4
|
-
//
|
|
5
|
-
// This is a great place to put global configuration and
|
|
6
|
-
// behavior that modifies Cypress.
|
|
7
|
-
//
|
|
8
|
-
// You can change the location of this file or turn off
|
|
9
|
-
// automatically serving support files with the
|
|
10
|
-
// 'supportFile' configuration option.
|
|
11
|
-
//
|
|
12
|
-
// You can read more here:
|
|
13
|
-
// https://on.cypress.io/configuration
|
|
14
|
-
// ***********************************************************
|
|
15
|
-
|
|
16
|
-
// Import commands.ts using ES2015 syntax:
|
|
17
|
-
import './commands';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"fileServerFolder": ".",
|
|
3
|
-
"fixturesFolder": "./<%= dir %>/fixtures",
|
|
4
|
-
"integrationFolder": "./<%= dir %>/integration",
|
|
5
|
-
"modifyObstructiveCode": false,
|
|
6
|
-
"supportFile": "./<%= dir %>/support/index.<%= ext %>",
|
|
7
|
-
"pluginsFile": false,
|
|
8
|
-
"video": true,
|
|
9
|
-
"videosFolder": "<%= offsetFromRoot %>dist/cypress/<%= projectRoot %>/videos",
|
|
10
|
-
"screenshotsFolder": "<%= offsetFromRoot %>dist/cypress/<%= projectRoot %>/screenshots",
|
|
11
|
-
"chromeWebSecurity": false
|
|
12
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|