@nx/cypress 17.0.4 → 17.0.6
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/LICENSE +1 -1
- package/README.md +4 -9
- package/generators.json +3 -3
- package/index.d.ts +2 -2
- package/index.js +4 -4
- package/migrations.json +0 -24
- package/package.json +6 -6
- package/plugins/cypress-preset.d.ts +19 -27
- package/plugins/cypress-preset.js +11 -102
- package/src/executors/cypress/cypress.impl.d.ts +1 -1
- package/src/executors/cypress/cypress.impl.js +152 -6
- package/src/executors/cypress/schema.json +1 -11
- package/src/generators/base-setup/base-setup.d.ts +0 -1
- package/src/generators/base-setup/base-setup.js +3 -26
- package/src/generators/component-configuration/component-configuration.d.ts +2 -3
- package/src/generators/component-configuration/component-configuration.js +27 -50
- package/src/generators/component-configuration/files/__directory__/support/component-index.html +1 -4
- package/src/generators/component-configuration/schema.d.ts +0 -7
- package/src/generators/component-configuration/schema.json +1 -1
- package/src/generators/configuration/configuration.d.ts +0 -4
- package/src/generators/configuration/configuration.js +26 -90
- package/src/generators/configuration/schema.json +1 -1
- package/src/generators/cypress-project/cypress-project.js +5 -25
- package/src/generators/cypress-project/schema.d.ts +0 -1
- package/src/generators/cypress-project/schema.json +1 -1
- package/src/generators/init/init.d.ts +0 -2
- package/src/generators/init/init.js +15 -71
- package/src/generators/init/schema.d.ts +2 -4
- package/src/generators/init/schema.json +1 -19
- package/src/generators/migrate-to-cypress-11/schema.json +1 -1
- package/src/utils/add-linter.d.ts +0 -1
- package/src/utils/add-linter.js +4 -4
- package/src/utils/config.d.ts +7 -6
- package/src/utils/config.js +12 -39
- package/src/utils/ct-helpers.d.ts +1 -1
- package/src/utils/ct-helpers.js +2 -6
- package/src/utils/versions.d.ts +3 -3
- package/src/utils/versions.js +3 -3
- package/plugin.d.ts +0 -1
- package/plugin.js +0 -6
- package/src/generators/base-setup/files/config-js-cjs/__directory__/support/commands.js__ext__ +0 -35
- package/src/generators/base-setup/files/config-js-cjs/cypress.config.js__ext__ +0 -3
- package/src/generators/base-setup/files/config-js-esm/__directory__/support/commands.js__ext__ +0 -35
- package/src/generators/base-setup/files/config-js-esm/cypress.config.js__ext__ +0 -3
- package/src/generators/base-setup/files/config-ts/__directory__/support/commands.ts__ext__ +0 -35
- package/src/migrations/update-18-1-0/update-cypress-version-13-6-6.d.ts +0 -2
- package/src/migrations/update-18-1-0/update-cypress-version-13-6-6.js +0 -12
- package/src/plugins/plugin.d.ts +0 -9
- package/src/plugins/plugin.js +0 -215
- package/src/utils/constants.d.ts +0 -4
- package/src/utils/constants.js +0 -7
- package/src/utils/start-dev-server.d.ts +0 -9
- package/src/utils/start-dev-server.js +0 -157
- /package/src/generators/base-setup/files/{common/__directory__ → __directory__}/fixtures/example.json +0 -0
- /package/src/generators/base-setup/files/{common/__directory__ → __directory__}/support/commands.ts__ext__ +0 -0
- /package/src/generators/base-setup/files/{common/__directory__ → __directory__}/tsconfig.json__ext__ +0 -0
- /package/src/generators/base-setup/files/{config-ts/cypress.config.ts__ext__ → cypress.config.ts__ext__} +0 -0
package/src/utils/add-linter.js
CHANGED
|
@@ -20,16 +20,17 @@ async function addLinterToCyProject(tree, options) {
|
|
|
20
20
|
linter: options.linter,
|
|
21
21
|
skipFormat: true,
|
|
22
22
|
tsConfigPaths: [(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json')],
|
|
23
|
+
eslintFilePatterns: [
|
|
24
|
+
`${projectConfig.root}/**/*.${options.js ? 'js' : '{js,ts}'}`,
|
|
25
|
+
],
|
|
23
26
|
setParserOptionsProject: options.setParserOptionsProject,
|
|
24
27
|
skipPackageJson: options.skipPackageJson,
|
|
25
28
|
rootProject: options.rootProject,
|
|
26
|
-
addPlugin: options.addPlugin,
|
|
27
29
|
}));
|
|
28
30
|
}
|
|
29
31
|
if (!options.linter || options.linter !== eslint_1.Linter.EsLint) {
|
|
30
32
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
31
33
|
}
|
|
32
|
-
options.overwriteExisting = options.overwriteExisting || !eslintFile;
|
|
33
34
|
tasks.push(!options.skipPackageJson
|
|
34
35
|
? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'eslint-plugin-cypress': versions_1.eslintPluginCypressVersion })
|
|
35
36
|
: () => { });
|
|
@@ -37,7 +38,6 @@ async function addLinterToCyProject(tree, options) {
|
|
|
37
38
|
const overrides = [];
|
|
38
39
|
if (options.rootProject) {
|
|
39
40
|
(0, eslint_file_1.addPluginsToLintConfig)(tree, projectConfig.root, '@nx');
|
|
40
|
-
overrides.push(global_eslint_config_1.typeScriptOverride);
|
|
41
41
|
overrides.push(global_eslint_config_1.javaScriptOverride);
|
|
42
42
|
}
|
|
43
43
|
(0, eslint_file_1.addExtendsToLintConfig)(tree, projectConfig.root, 'plugin:cypress/recommended');
|
|
@@ -55,7 +55,7 @@ async function addLinterToCyProject(tree, options) {
|
|
|
55
55
|
};
|
|
56
56
|
const addCy6Override = cyVersion && cyVersion < 7;
|
|
57
57
|
if (options.overwriteExisting) {
|
|
58
|
-
overrides.
|
|
58
|
+
overrides.push({
|
|
59
59
|
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
|
|
60
60
|
parserOptions: !options.setParserOptionsProject
|
|
61
61
|
? undefined
|
package/src/utils/config.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export declare function addDefaultE2EConfig(cyConfigContents: string, options: {
|
|
2
|
+
directory: string;
|
|
3
|
+
bundler?: string;
|
|
4
|
+
}): Promise<string>;
|
|
5
5
|
/**
|
|
6
6
|
* Adds the nxComponentTestingPreset to the cypress config file
|
|
7
7
|
* Make sure after calling this the correct import statement is addeda
|
|
8
8
|
* to bring in the nxComponentTestingPreset function
|
|
9
9
|
**/
|
|
10
|
-
export declare function addDefaultCTConfig(cyConfigContents: string, options?:
|
|
10
|
+
export declare function addDefaultCTConfig(cyConfigContents: string, options?: {
|
|
11
|
+
bundler?: string;
|
|
12
|
+
}): Promise<string>;
|
|
11
13
|
/**
|
|
12
14
|
* Adds the mount command for Cypress
|
|
13
15
|
* Make sure after calling this the correct import statement is added
|
|
14
16
|
* to bring in the correct mount from cypress.
|
|
15
17
|
**/
|
|
16
18
|
export declare function addMountDefinition(cmpCommandFileContents: string): Promise<string>;
|
|
17
|
-
export declare function getProjectCypressConfigPath(tree: Tree, projectRoot: string): string;
|
package/src/utils/config.js
CHANGED
|
@@ -1,40 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const TS_QUERY_COMMON_JS_EXPORT_SELECTOR = 'BinaryExpression:has(Identifier[name="module"]):has(Identifier[name="exports"])';
|
|
7
|
-
const TS_QUERY_EXPORT_CONFIG_PREFIX = `:matches(ExportAssignment, ${TS_QUERY_COMMON_JS_EXPORT_SELECTOR}) `;
|
|
8
|
-
async function addDefaultE2EConfig(cyConfigContents, options, baseUrl) {
|
|
3
|
+
exports.addMountDefinition = exports.addDefaultCTConfig = exports.addDefaultE2EConfig = void 0;
|
|
4
|
+
const TS_QUERY_EXPORT_CONFIG_PREFIX = ':matches(ExportAssignment, BinaryExpression:has(Identifier[name="module"]):has(Identifier[name="exports"]))';
|
|
5
|
+
async function addDefaultE2EConfig(cyConfigContents, options) {
|
|
9
6
|
if (!cyConfigContents) {
|
|
10
7
|
throw new Error('The passed in cypress config file is empty!');
|
|
11
8
|
}
|
|
12
9
|
const { tsquery } = await Promise.resolve().then(() => require('@phenomnomnominal/tsquery'));
|
|
13
|
-
const isCommonJS = tsquery.query(cyConfigContents, TS_QUERY_COMMON_JS_EXPORT_SELECTOR).length >
|
|
14
|
-
0;
|
|
15
10
|
const testingTypeConfig = tsquery.query(cyConfigContents, `${TS_QUERY_EXPORT_CONFIG_PREFIX} PropertyAssignment:has(Identifier[name="e2e"])`);
|
|
16
11
|
let updatedConfigContents = cyConfigContents;
|
|
17
12
|
if (testingTypeConfig.length === 0) {
|
|
18
|
-
const configValue =
|
|
13
|
+
const configValue = options.bundler === 'vite'
|
|
14
|
+
? `nxE2EPreset(__filename, { cypressDir: '${options.directory}', bundler: 'vite' })`
|
|
15
|
+
: `nxE2EPreset(__filename, { cypressDir: '${options.directory}' })`;
|
|
19
16
|
updatedConfigContents = tsquery.replace(cyConfigContents, `${TS_QUERY_EXPORT_CONFIG_PREFIX} ObjectLiteralExpression:first-child`, (node) => {
|
|
20
|
-
let baseUrlContents = baseUrl ? `,\nbaseUrl: '${baseUrl}'` : '';
|
|
21
17
|
if (node.properties.length > 0) {
|
|
22
18
|
return `{
|
|
23
19
|
${node.properties.map((p) => p.getText()).join(',\n')},
|
|
24
|
-
e2e: {
|
|
20
|
+
e2e: ${configValue}
|
|
25
21
|
}`;
|
|
26
22
|
}
|
|
27
23
|
return `{
|
|
28
|
-
e2e: {
|
|
24
|
+
e2e: ${configValue}
|
|
29
25
|
}`;
|
|
30
26
|
});
|
|
31
|
-
|
|
32
|
-
? `const { nxE2EPreset } = require('@nx/cypress/plugins/cypress-preset');
|
|
33
|
-
|
|
34
|
-
${updatedConfigContents}`
|
|
35
|
-
: `import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
|
|
36
|
-
|
|
37
|
-
${updatedConfigContents}`;
|
|
27
|
+
updatedConfigContents = `import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';\n${updatedConfigContents}`;
|
|
38
28
|
}
|
|
39
29
|
return updatedConfigContents;
|
|
40
30
|
}
|
|
@@ -52,16 +42,9 @@ async function addDefaultCTConfig(cyConfigContents, options = {}) {
|
|
|
52
42
|
const testingTypeConfig = tsquery.query(cyConfigContents, `${TS_QUERY_EXPORT_CONFIG_PREFIX} PropertyAssignment:has(Identifier[name="component"])`);
|
|
53
43
|
let updatedConfigContents = cyConfigContents;
|
|
54
44
|
if (testingTypeConfig.length === 0) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// vite is the default bundler, so we don't need to set it
|
|
59
|
-
delete options.bundler;
|
|
60
|
-
}
|
|
61
|
-
if (Object.keys(options).length) {
|
|
62
|
-
configValue = `nxComponentTestingPreset(__filename, ${JSON.stringify(options)})`;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
45
|
+
const configValue = options?.bundler === 'vite'
|
|
46
|
+
? "nxComponentTestingPreset(__filename, { bundler: 'vite' })"
|
|
47
|
+
: 'nxComponentTestingPreset(__filename)';
|
|
65
48
|
updatedConfigContents = tsquery.replace(cyConfigContents, `${TS_QUERY_EXPORT_CONFIG_PREFIX} ObjectLiteralExpression:first-child`, (node) => {
|
|
66
49
|
if (node.properties.length > 0) {
|
|
67
50
|
return `{
|
|
@@ -103,13 +86,3 @@ async function addMountDefinition(cmpCommandFileContents) {
|
|
|
103
86
|
return `${updatedInterface}\n${mountCommand}`;
|
|
104
87
|
}
|
|
105
88
|
exports.addMountDefinition = addMountDefinition;
|
|
106
|
-
function getProjectCypressConfigPath(tree, projectRoot) {
|
|
107
|
-
const cypressConfigPaths = (0, devkit_1.glob)(tree, [
|
|
108
|
-
(0, devkit_1.joinPathFragments)(projectRoot, exports.CYPRESS_CONFIG_FILE_NAME_PATTERN),
|
|
109
|
-
]);
|
|
110
|
-
if (cypressConfigPaths.length === 0) {
|
|
111
|
-
throw new Error(`Could not find a cypress config file in ${projectRoot}.`);
|
|
112
|
-
}
|
|
113
|
-
return cypressConfigPaths[0];
|
|
114
|
-
}
|
|
115
|
-
exports.getProjectCypressConfigPath = getProjectCypressConfigPath;
|
|
@@ -11,6 +11,6 @@ export declare function getTempTailwindPath(context: ExecutorContext): string;
|
|
|
11
11
|
* Checks if the childProjectName is a descendent of the parentProjectName
|
|
12
12
|
* in the project graph
|
|
13
13
|
**/
|
|
14
|
-
export declare function isCtProjectUsingBuildProject(graph: ProjectGraph, parentProjectName: string, childProjectName: string
|
|
14
|
+
export declare function isCtProjectUsingBuildProject(graph: ProjectGraph, parentProjectName: string, childProjectName: string): boolean;
|
|
15
15
|
export declare function getProjectConfigByPath(graph: ProjectGraph, configPath: string): ProjectConfiguration;
|
|
16
16
|
export declare function createExecutorContext(graph: ProjectGraph, targets: Record<string, TargetConfiguration>, projectName: string, targetName: string, configurationName: string): ExecutorContext;
|
package/src/utils/ct-helpers.js
CHANGED
|
@@ -30,18 +30,14 @@ exports.getTempTailwindPath = getTempTailwindPath;
|
|
|
30
30
|
* Checks if the childProjectName is a descendent of the parentProjectName
|
|
31
31
|
* in the project graph
|
|
32
32
|
**/
|
|
33
|
-
function isCtProjectUsingBuildProject(graph, parentProjectName, childProjectName
|
|
34
|
-
if (seen.has(parentProjectName)) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
seen.add(parentProjectName);
|
|
33
|
+
function isCtProjectUsingBuildProject(graph, parentProjectName, childProjectName) {
|
|
38
34
|
const isProjectDirectDep = graph.dependencies[parentProjectName].some((p) => p.target === childProjectName);
|
|
39
35
|
if (isProjectDirectDep) {
|
|
40
36
|
return true;
|
|
41
37
|
}
|
|
42
38
|
const maybeIntermediateProjects = graph.dependencies[parentProjectName].filter((p) => !graph.externalNodes[p.target]);
|
|
43
39
|
for (const maybeIntermediateProject of maybeIntermediateProjects) {
|
|
44
|
-
if (isCtProjectUsingBuildProject(graph, maybeIntermediateProject.target, childProjectName
|
|
40
|
+
if (isCtProjectUsingBuildProject(graph, maybeIntermediateProject.target, childProjectName)) {
|
|
45
41
|
return true;
|
|
46
42
|
}
|
|
47
43
|
}
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const nxVersion: any;
|
|
2
2
|
export declare const eslintPluginCypressVersion = "^2.13.4";
|
|
3
|
-
export declare const typesNodeVersion = "
|
|
3
|
+
export declare const typesNodeVersion = "16.11.7";
|
|
4
4
|
export declare const cypressViteDevServerVersion = "^2.2.1";
|
|
5
|
-
export declare const cypressVersion = "^13.
|
|
5
|
+
export declare const cypressVersion = "^13.0.0";
|
|
6
6
|
export declare const cypressWebpackVersion = "^2.0.0";
|
|
7
7
|
export declare const webpackHttpPluginVersion = "^5.5.0";
|
|
8
|
-
export declare const viteVersion = "~
|
|
8
|
+
export declare const viteVersion = "~4.3.9";
|
|
9
9
|
export declare const htmlWebpackPluginVersion = "^5.5.0";
|
package/src/utils/versions.js
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.htmlWebpackPluginVersion = exports.viteVersion = exports.webpackHttpPluginVersion = exports.cypressWebpackVersion = exports.cypressVersion = exports.cypressViteDevServerVersion = exports.typesNodeVersion = exports.eslintPluginCypressVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
5
|
exports.eslintPluginCypressVersion = '^2.13.4';
|
|
6
|
-
exports.typesNodeVersion = '
|
|
6
|
+
exports.typesNodeVersion = '16.11.7';
|
|
7
7
|
exports.cypressViteDevServerVersion = '^2.2.1';
|
|
8
|
-
exports.cypressVersion = '^13.
|
|
8
|
+
exports.cypressVersion = '^13.0.0';
|
|
9
9
|
exports.cypressWebpackVersion = '^2.0.0';
|
|
10
10
|
exports.webpackHttpPluginVersion = '^5.5.0';
|
|
11
|
-
exports.viteVersion = '~
|
|
11
|
+
exports.viteVersion = '~4.3.9';
|
|
12
12
|
exports.htmlWebpackPluginVersion = '^5.5.0';
|
package/plugin.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createNodes, createDependencies } from './src/plugins/plugin';
|
package/plugin.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDependencies = exports.createNodes = void 0;
|
|
4
|
-
var plugin_1 = require("./src/plugins/plugin");
|
|
5
|
-
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
|
|
6
|
-
Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
|
package/src/generators/base-setup/files/config-js-cjs/__directory__/support/commands.js__ext__
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/// <reference types="cypress" />
|
|
2
|
-
|
|
3
|
-
// ***********************************************
|
|
4
|
-
// This example commands.ts shows you how to
|
|
5
|
-
// create various custom commands and overwrite
|
|
6
|
-
// existing commands.
|
|
7
|
-
//
|
|
8
|
-
// For more comprehensive examples of custom
|
|
9
|
-
// commands please read more here:
|
|
10
|
-
// https://on.cypress.io/custom-commands
|
|
11
|
-
// ***********************************************
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
14
|
-
declare namespace Cypress {
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
-
interface Chainable<Subject> {
|
|
17
|
-
login(email: string, password: string): void;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// -- This is a parent command --
|
|
22
|
-
Cypress.Commands.add('login', (email, password) => {
|
|
23
|
-
console.log('Custom command example: Login', email, password);
|
|
24
|
-
});
|
|
25
|
-
//
|
|
26
|
-
// -- This is a child command --
|
|
27
|
-
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
// -- This is a dual command --
|
|
31
|
-
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
// -- This will overwrite an existing command --
|
|
35
|
-
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
package/src/generators/base-setup/files/config-js-esm/__directory__/support/commands.js__ext__
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/// <reference types="cypress" />
|
|
2
|
-
|
|
3
|
-
// ***********************************************
|
|
4
|
-
// This example commands.ts shows you how to
|
|
5
|
-
// create various custom commands and overwrite
|
|
6
|
-
// existing commands.
|
|
7
|
-
//
|
|
8
|
-
// For more comprehensive examples of custom
|
|
9
|
-
// commands please read more here:
|
|
10
|
-
// https://on.cypress.io/custom-commands
|
|
11
|
-
// ***********************************************
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
14
|
-
declare namespace Cypress {
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
-
interface Chainable<Subject> {
|
|
17
|
-
login(email: string, password: string): void;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// -- This is a parent command --
|
|
22
|
-
Cypress.Commands.add('login', (email, password) => {
|
|
23
|
-
console.log('Custom command example: Login', email, password);
|
|
24
|
-
});
|
|
25
|
-
//
|
|
26
|
-
// -- This is a child command --
|
|
27
|
-
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
// -- This is a dual command --
|
|
31
|
-
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
// -- This will overwrite an existing command --
|
|
35
|
-
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/// <reference types="cypress" />
|
|
2
|
-
|
|
3
|
-
// ***********************************************
|
|
4
|
-
// This example commands.ts shows you how to
|
|
5
|
-
// create various custom commands and overwrite
|
|
6
|
-
// existing commands.
|
|
7
|
-
//
|
|
8
|
-
// For more comprehensive examples of custom
|
|
9
|
-
// commands please read more here:
|
|
10
|
-
// https://on.cypress.io/custom-commands
|
|
11
|
-
// ***********************************************
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
14
|
-
declare namespace Cypress {
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
|
-
interface Chainable<Subject> {
|
|
17
|
-
login(email: string, password: string): void;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// -- This is a parent command --
|
|
22
|
-
Cypress.Commands.add('login', (email, password) => {
|
|
23
|
-
console.log('Custom command example: Login', email, password);
|
|
24
|
-
});
|
|
25
|
-
//
|
|
26
|
-
// -- This is a child command --
|
|
27
|
-
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
// -- This is a dual command --
|
|
31
|
-
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
// -- This will overwrite an existing command --
|
|
35
|
-
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
|
@@ -1,12 +0,0 @@
|
|
|
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/plugins/plugin.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CreateDependencies, CreateNodes } from '@nx/devkit';
|
|
2
|
-
export interface CypressPluginOptions {
|
|
3
|
-
ciTargetName?: string;
|
|
4
|
-
targetName?: string;
|
|
5
|
-
openTargetName?: string;
|
|
6
|
-
componentTestingTargetName?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const createDependencies: CreateDependencies;
|
|
9
|
-
export declare const createNodes: CreateNodes<CypressPluginOptions>;
|
package/src/plugins/plugin.js
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNodes = exports.createDependencies = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const js_1 = require("@nx/js");
|
|
7
|
-
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const workspace_context_1 = require("nx/src/utils/workspace-context");
|
|
10
|
-
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
|
11
|
-
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
12
|
-
const constants_1 = require("../utils/constants");
|
|
13
|
-
const config_utils_1 = require("@nx/devkit/src/utils/config-utils");
|
|
14
|
-
const cachePath = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'cypress.hash');
|
|
15
|
-
const targetsCache = (0, fs_1.existsSync)(cachePath) ? readTargetsCache() : {};
|
|
16
|
-
const calculatedTargets = {};
|
|
17
|
-
function readTargetsCache() {
|
|
18
|
-
return (0, devkit_1.readJsonFile)(cachePath);
|
|
19
|
-
}
|
|
20
|
-
function writeTargetsToCache(targets) {
|
|
21
|
-
(0, devkit_1.writeJsonFile)(cachePath, targets);
|
|
22
|
-
}
|
|
23
|
-
const createDependencies = () => {
|
|
24
|
-
writeTargetsToCache(calculatedTargets);
|
|
25
|
-
return [];
|
|
26
|
-
};
|
|
27
|
-
exports.createDependencies = createDependencies;
|
|
28
|
-
exports.createNodes = [
|
|
29
|
-
'**/cypress.config.{js,ts,mjs,cjs}',
|
|
30
|
-
async (configFilePath, options, context) => {
|
|
31
|
-
options = normalizeOptions(options);
|
|
32
|
-
const projectRoot = (0, path_1.dirname)(configFilePath);
|
|
33
|
-
// Do not create a project if package.json and project.json isn't there.
|
|
34
|
-
const siblingFiles = (0, fs_1.readdirSync)((0, path_1.join)(context.workspaceRoot, projectRoot));
|
|
35
|
-
if (!siblingFiles.includes('package.json') &&
|
|
36
|
-
!siblingFiles.includes('project.json')) {
|
|
37
|
-
return {};
|
|
38
|
-
}
|
|
39
|
-
const hash = (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options, context, [
|
|
40
|
-
(0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot)),
|
|
41
|
-
]);
|
|
42
|
-
const { targets, targetGroups } = targetsCache[hash]
|
|
43
|
-
? targetsCache[hash]
|
|
44
|
-
: await buildCypressTargets(configFilePath, projectRoot, options, context);
|
|
45
|
-
calculatedTargets[hash] = { targets, targetGroups };
|
|
46
|
-
const project = {
|
|
47
|
-
projectType: 'application',
|
|
48
|
-
targets,
|
|
49
|
-
metadata: {
|
|
50
|
-
technologies: ['cypress'],
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
if (targetGroups) {
|
|
54
|
-
project.metadata.targetGroups = targetGroups;
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
projects: {
|
|
58
|
-
[projectRoot]: project,
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
},
|
|
62
|
-
];
|
|
63
|
-
function getOutputs(projectRoot, cypressConfig, testingType) {
|
|
64
|
-
function getOutput(path) {
|
|
65
|
-
if (path.startsWith('..')) {
|
|
66
|
-
return (0, devkit_1.joinPathFragments)('{workspaceRoot}', projectRoot, path);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return (0, devkit_1.joinPathFragments)('{projectRoot}', path);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const { screenshotsFolder, videosFolder, e2e, component } = cypressConfig;
|
|
73
|
-
const outputs = [];
|
|
74
|
-
if (videosFolder) {
|
|
75
|
-
outputs.push(getOutput(videosFolder));
|
|
76
|
-
}
|
|
77
|
-
if (screenshotsFolder) {
|
|
78
|
-
outputs.push(getOutput(screenshotsFolder));
|
|
79
|
-
}
|
|
80
|
-
switch (testingType) {
|
|
81
|
-
case 'e2e': {
|
|
82
|
-
if (e2e.videosFolder) {
|
|
83
|
-
outputs.push(getOutput(e2e.videosFolder));
|
|
84
|
-
}
|
|
85
|
-
if (e2e.screenshotsFolder) {
|
|
86
|
-
outputs.push(getOutput(e2e.screenshotsFolder));
|
|
87
|
-
}
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
case 'component': {
|
|
91
|
-
if (component.videosFolder) {
|
|
92
|
-
outputs.push(getOutput(component.videosFolder));
|
|
93
|
-
}
|
|
94
|
-
if (component.screenshotsFolder) {
|
|
95
|
-
outputs.push(getOutput(component.screenshotsFolder));
|
|
96
|
-
}
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return outputs;
|
|
101
|
-
}
|
|
102
|
-
async function buildCypressTargets(configFilePath, projectRoot, options, context) {
|
|
103
|
-
const cypressConfig = await (0, config_utils_1.loadConfigFile)((0, path_1.join)(context.workspaceRoot, configFilePath));
|
|
104
|
-
const pluginPresetOptions = {
|
|
105
|
-
...cypressConfig.e2e?.[constants_1.NX_PLUGIN_OPTIONS],
|
|
106
|
-
...cypressConfig.env,
|
|
107
|
-
...cypressConfig.e2e?.env,
|
|
108
|
-
};
|
|
109
|
-
const webServerCommands = pluginPresetOptions?.webServerCommands;
|
|
110
|
-
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
111
|
-
const targets = {};
|
|
112
|
-
let targetGroups;
|
|
113
|
-
if ('e2e' in cypressConfig) {
|
|
114
|
-
targets[options.targetName] = {
|
|
115
|
-
command: `cypress run`,
|
|
116
|
-
options: { cwd: projectRoot },
|
|
117
|
-
cache: true,
|
|
118
|
-
inputs: getInputs(namedInputs),
|
|
119
|
-
outputs: getOutputs(projectRoot, cypressConfig, 'e2e'),
|
|
120
|
-
};
|
|
121
|
-
if (webServerCommands?.default) {
|
|
122
|
-
delete webServerCommands.default;
|
|
123
|
-
}
|
|
124
|
-
if (Object.keys(webServerCommands ?? {}).length > 0) {
|
|
125
|
-
targets[options.targetName].configurations ??= {};
|
|
126
|
-
for (const [configuration, webServerCommand] of Object.entries(webServerCommands ?? {})) {
|
|
127
|
-
targets[options.targetName].configurations[configuration] = {
|
|
128
|
-
command: `cypress run --env webServerCommand="${webServerCommand}"`,
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
const ciWebServerCommand = pluginPresetOptions?.ciWebServerCommand;
|
|
133
|
-
if (ciWebServerCommand) {
|
|
134
|
-
const specPatterns = Array.isArray(cypressConfig.e2e.specPattern)
|
|
135
|
-
? cypressConfig.e2e.specPattern.map((p) => (0, path_1.join)(projectRoot, p))
|
|
136
|
-
: [(0, path_1.join)(projectRoot, cypressConfig.e2e.specPattern)];
|
|
137
|
-
const excludeSpecPatterns = !cypressConfig.e2e
|
|
138
|
-
.excludeSpecPattern
|
|
139
|
-
? cypressConfig.e2e.excludeSpecPattern
|
|
140
|
-
: Array.isArray(cypressConfig.e2e.excludeSpecPattern)
|
|
141
|
-
? cypressConfig.e2e.excludeSpecPattern.map((p) => (0, path_1.join)(projectRoot, p))
|
|
142
|
-
: [(0, path_1.join)(projectRoot, cypressConfig.e2e.excludeSpecPattern)];
|
|
143
|
-
const specFiles = (0, workspace_context_1.globWithWorkspaceContext)(context.workspaceRoot, specPatterns, excludeSpecPatterns);
|
|
144
|
-
const dependsOn = [];
|
|
145
|
-
const outputs = getOutputs(projectRoot, cypressConfig, 'e2e');
|
|
146
|
-
const inputs = getInputs(namedInputs);
|
|
147
|
-
const groupName = 'E2E (CI)';
|
|
148
|
-
targetGroups = { [groupName]: [] };
|
|
149
|
-
const ciTargetGroup = targetGroups[groupName];
|
|
150
|
-
for (const file of specFiles) {
|
|
151
|
-
const relativeSpecFilePath = (0, devkit_1.normalizePath)((0, path_1.relative)(projectRoot, file));
|
|
152
|
-
const targetName = options.ciTargetName + '--' + relativeSpecFilePath;
|
|
153
|
-
ciTargetGroup.push(targetName);
|
|
154
|
-
targets[targetName] = {
|
|
155
|
-
outputs,
|
|
156
|
-
inputs,
|
|
157
|
-
cache: true,
|
|
158
|
-
command: `cypress run --env webServerCommand="${ciWebServerCommand}" --spec ${relativeSpecFilePath}`,
|
|
159
|
-
options: {
|
|
160
|
-
cwd: projectRoot,
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
dependsOn.push({
|
|
164
|
-
target: targetName,
|
|
165
|
-
projects: 'self',
|
|
166
|
-
params: 'forward',
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
targets[options.ciTargetName] = {
|
|
170
|
-
executor: 'nx:noop',
|
|
171
|
-
cache: true,
|
|
172
|
-
inputs,
|
|
173
|
-
outputs,
|
|
174
|
-
dependsOn,
|
|
175
|
-
};
|
|
176
|
-
ciTargetGroup.push(options.ciTargetName);
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
targetGroups = null;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if ('component' in cypressConfig) {
|
|
183
|
-
// This will not override the e2e target if it is the same
|
|
184
|
-
targets[options.componentTestingTargetName] ??= {
|
|
185
|
-
command: `cypress run --component`,
|
|
186
|
-
options: { cwd: projectRoot },
|
|
187
|
-
cache: true,
|
|
188
|
-
inputs: getInputs(namedInputs),
|
|
189
|
-
outputs: getOutputs(projectRoot, cypressConfig, 'component'),
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
targets[options.openTargetName] = {
|
|
193
|
-
command: `cypress open`,
|
|
194
|
-
options: { cwd: projectRoot },
|
|
195
|
-
};
|
|
196
|
-
return { targets, targetGroups };
|
|
197
|
-
}
|
|
198
|
-
function normalizeOptions(options) {
|
|
199
|
-
options ??= {};
|
|
200
|
-
options.targetName ??= 'e2e';
|
|
201
|
-
options.openTargetName ??= 'open-cypress';
|
|
202
|
-
options.componentTestingTargetName ??= 'component-test';
|
|
203
|
-
options.ciTargetName ??= 'e2e-ci';
|
|
204
|
-
return options;
|
|
205
|
-
}
|
|
206
|
-
function getInputs(namedInputs) {
|
|
207
|
-
return [
|
|
208
|
-
...('production' in namedInputs
|
|
209
|
-
? ['default', '^production']
|
|
210
|
-
: ['default', '^default']),
|
|
211
|
-
{
|
|
212
|
-
externalDependencies: ['cypress'],
|
|
213
|
-
},
|
|
214
|
-
];
|
|
215
|
-
}
|
package/src/utils/constants.d.ts
DELETED
package/src/utils/constants.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import { CypressExecutorOptions } from '../executors/cypress/cypress.impl';
|
|
3
|
-
export declare function startDevServer(opts: Omit<CypressExecutorOptions, 'cypressConfig'>, context: ExecutorContext): AsyncGenerator<{
|
|
4
|
-
baseUrl: any;
|
|
5
|
-
portLockFilePath?: undefined;
|
|
6
|
-
} | {
|
|
7
|
-
baseUrl: any;
|
|
8
|
-
portLockFilePath: string;
|
|
9
|
-
}, void, unknown>;
|