@nx/cypress 16.1.3 → 16.2.0-beta.0
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 +6 -6
- package/src/generators/base-setup/base-setup.d.ts +10 -0
- package/src/generators/base-setup/base-setup.js +47 -0
- package/src/generators/base-setup/base-setup.js.map +1 -0
- package/src/generators/{cypress-e2e-configuration/files/v9/__dir__/support/commands.ts__tmpl__ → base-setup/files/__directory__/support/commands.ts__ext__} +8 -6
- package/src/generators/base-setup/files/__directory__/tsconfig.json +20 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.d.ts +1 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js +28 -17
- package/src/generators/cypress-component-configuration/cypress-component-configuration.js.map +1 -1
- package/src/generators/{cypress-e2e-configuration/files/v10/__dir__/support/e2e.ts__tmpl__ → cypress-component-configuration/files/__directory__/support/component.ts__ext__} +12 -2
- package/src/generators/cypress-component-configuration/schema.d.ts +1 -0
- package/src/generators/cypress-component-configuration/schema.json +6 -1
- package/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.js +44 -44
- package/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.js.map +1 -1
- package/src/generators/{cypress-component-configuration/files/cypress/support/component.ts__ext__ → cypress-e2e-configuration/files/v10/__directory__/support/e2e.ts__tmpl__} +1 -1
- package/src/generators/migrate-to-cypress-11/schema.json +1 -1
- package/src/migrations/update-16-2-0/update-cy-tsconfig.d.ts +3 -0
- package/src/migrations/update-16-2-0/update-cy-tsconfig.js +77 -0
- package/src/migrations/update-16-2-0/update-cy-tsconfig.js.map +1 -0
- package/src/utils/config.d.ts +18 -0
- package/src/utils/config.js +97 -0
- package/src/utils/config.js.map +1 -0
- package/src/generators/cypress-component-configuration/files/cypress/support/commands.ts__ext__ +0 -42
- package/src/generators/cypress-component-configuration/files/cypress/tsconfig.cy.json +0 -17
- package/src/generators/cypress-e2e-configuration/files/v10/cypress.config.ts__tmpl__ +0 -9
- package/src/generators/cypress-e2e-configuration/files/v10/tsconfig__tsFileExt__ +0 -10
- package/src/generators/cypress-e2e-configuration/files/v9/__dir__/fixtures/example.json__tmpl__ +0 -4
- /package/src/generators/{cypress-component-configuration/files/cypress → base-setup/files/__directory__}/fixtures/example.json +0 -0
- /package/src/generators/{cypress-component-configuration → base-setup}/files/cypress.config.ts__ext__ +0 -0
- /package/src/generators/cypress-component-configuration/files/{cypress → __directory__}/support/component-index.html +0 -0
- /package/src/generators/cypress-e2e-configuration/files/v10/{__dir__ → __directory__}/e2e/app.cy.ts__tmpl__ +0 -0
- /package/src/generators/cypress-e2e-configuration/files/v10/{__dir__ → __directory__}/support/app.po.ts__tmpl__ +0 -0
- /package/src/generators/cypress-e2e-configuration/files/{v10/__dir__ → v9/__directory__}/fixtures/example.json__tmpl__ +0 -0
- /package/src/generators/cypress-e2e-configuration/files/v9/{__dir__ → __directory__}/integration/app.spec.ts__tmpl__ +0 -0
- /package/src/generators/cypress-e2e-configuration/files/v9/{__dir__ → __directory__}/plugins/index.js +0 -0
- /package/src/generators/cypress-e2e-configuration/files/v9/{__dir__ → __directory__}/support/app.po.ts__tmpl__ +0 -0
- /package/src/generators/cypress-e2e-configuration/files/{v10/__dir__ → v9/__directory__}/support/commands.ts__tmpl__ +0 -0
- /package/src/generators/cypress-e2e-configuration/files/v9/{__dir__ → __directory__}/support/index.ts__tmpl__ +0 -0
- /package/src/generators/cypress-e2e-configuration/files/v9/{tsconfig__tsFileExt__ → __directory__/tsconfig.json} +0 -0
package/migrations.json
CHANGED
|
@@ -47,6 +47,12 @@
|
|
|
47
47
|
"version": "16.0.0-beta.1",
|
|
48
48
|
"description": "Replace @nrwl/cypress with @nx/cypress",
|
|
49
49
|
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
50
|
+
},
|
|
51
|
+
"update-16-2-0-normalize-tsconfigs": {
|
|
52
|
+
"cli": "nx",
|
|
53
|
+
"version": "16.2.0-beta.0",
|
|
54
|
+
"description": "Normalize tsconfig.cy.json files to be located at '<projectRoot>/cypress/tsconfig.json'",
|
|
55
|
+
"implementation": "./src/migrations/update-16-2-0/update-cy-tsconfig"
|
|
50
56
|
}
|
|
51
57
|
},
|
|
52
58
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/cypress",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.2.0-beta.0",
|
|
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,10 +34,10 @@
|
|
|
34
34
|
"migrations": "./migrations.json"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nrwl/cypress": "16.
|
|
38
|
-
"@nx/devkit": "16.
|
|
39
|
-
"@nx/js": "16.
|
|
40
|
-
"@nx/linter": "16.
|
|
37
|
+
"@nrwl/cypress": "16.2.0-beta.0",
|
|
38
|
+
"@nx/devkit": "16.2.0-beta.0",
|
|
39
|
+
"@nx/js": "16.2.0-beta.0",
|
|
40
|
+
"@nx/linter": "16.2.0-beta.0",
|
|
41
41
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
42
42
|
"detect-port": "^1.5.1",
|
|
43
43
|
"dotenv": "~10.0.0",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
57
|
"types": "./index.d.ts",
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "f7ba85e8ec9c074eaee81731a20aee7ea6dbc8aa"
|
|
59
59
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
export interface CypressBaseSetupSchema {
|
|
3
|
+
project: string;
|
|
4
|
+
/**
|
|
5
|
+
* directory from the projectRoot where cypress files will be generated
|
|
6
|
+
* default is `cypress`
|
|
7
|
+
* */
|
|
8
|
+
directory?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function addBaseCypressSetup(tree: Tree, options: CypressBaseSetupSchema): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addBaseCypressSetup = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const js_1 = require("@nx/js");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
function addBaseCypressSetup(tree, options) {
|
|
8
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
9
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.ts'))) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const opts = normalizeOptions(tree, projectConfig, options);
|
|
13
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), projectConfig.root, Object.assign(Object.assign({}, opts), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(projectConfig.root), offsetFromProjectRoot: opts.hasTsConfig ? opts.offsetFromProjectRoot : '', tsConfigPath: opts.hasTsConfig
|
|
14
|
+
? `${opts.offsetFromProjectRoot}tsconfig.json`
|
|
15
|
+
: (0, js_1.getRelativePathToRootTsConfig)(tree, projectConfig.root), ext: '' }));
|
|
16
|
+
if (opts.hasTsConfig) {
|
|
17
|
+
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'), (json) => {
|
|
18
|
+
// tsconfig doesn't have references so it shouldn't add them
|
|
19
|
+
// like in the case of nextjs apps.
|
|
20
|
+
if (!json.references) {
|
|
21
|
+
return json;
|
|
22
|
+
}
|
|
23
|
+
const tsconfigPath = `./${options.directory}/tsconfig.json`;
|
|
24
|
+
if (!json.references.some((ref) => ref.path === tsconfigPath)) {
|
|
25
|
+
json.references.push({
|
|
26
|
+
path: tsconfigPath,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return json;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
tree.rename((0, devkit_1.joinPathFragments)(projectConfig.root, options.directory, 'tsconfig.json'), (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.addBaseCypressSetup = addBaseCypressSetup;
|
|
37
|
+
function normalizeOptions(tree, projectConfig, options) {
|
|
38
|
+
var _a;
|
|
39
|
+
(_a = options.directory) !== null && _a !== void 0 ? _a : (options.directory = 'cypress');
|
|
40
|
+
const offsetFromProjectRoot = options.directory
|
|
41
|
+
.split('/')
|
|
42
|
+
.map((_) => '..')
|
|
43
|
+
.join('/');
|
|
44
|
+
const hasTsConfig = tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'));
|
|
45
|
+
return Object.assign(Object.assign({}, options), { projectConfig, offsetFromProjectRoot: `${offsetFromProjectRoot}/`, hasTsConfig });
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=base-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-setup.js","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/base-setup/base-setup.ts"],"names":[],"mappings":";;;AAAA,uCAQoB;AACpB,+BAAuD;AACvD,+BAA4B;AAW5B,SAAgB,mBAAmB,CACjC,IAAU,EACV,OAA+B;IAE/B,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtE,IAAI,IAAI,CAAC,MAAM,CAAC,IAAA,0BAAiB,EAAC,aAAa,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,EAAE;QAC3E,OAAO;KACR;IAED,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,a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AiB,EAAC,aAAa,CAAC,IAAI,EAAE,eAAe,CAAC,CACvD,CAAC;KACH;AACH,CAAC;AAjDD,kDAiDC;AAED,SAAS,gBAAgB,CACvB,IAAU,EACV,aAAmC,EACnC,OAA+B;;IAE/B,MAAA,OAAO,CAAC,SAAS,oCAAjB,OAAO,CAAC,SAAS,GAAK,SAAS,EAAC;IAEhC,MAAM,qBAAqB,GAAG,OAAO,CAAC,SAAS;SAC5C,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;SAChB,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAC7B,IAAA,0BAAiB,EAAC,aAAa,CAAC,IAAI,EAAE,eAAe,CAAC,CACvD,CAAC;IAEF,uCACK,OAAO,KACV,aAAa,EACb,qBAAqB,EAAE,GAAG,qBAAqB,GAAG,EAClD,WAAW,IACX;AACJ,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
|
|
1
3
|
// ***********************************************
|
|
2
|
-
// This example commands.
|
|
4
|
+
// This example commands.ts shows you how to
|
|
3
5
|
// create various custom commands and overwrite
|
|
4
6
|
// existing commands.
|
|
5
7
|
//
|
|
@@ -7,15 +9,15 @@
|
|
|
7
9
|
// commands please read more here:
|
|
8
10
|
// https://on.cypress.io/custom-commands
|
|
9
11
|
// ***********************************************
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
12
|
-
declare namespace Cypress {
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
14
|
+
declare namespace Cypress {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
16
|
interface Chainable<Subject> {
|
|
15
17
|
login(email: string, password: string): void;
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
|
-
|
|
20
|
+
|
|
19
21
|
// -- This is a parent command --
|
|
20
22
|
Cypress.Commands.add('login', (email, password) => {
|
|
21
23
|
console.log('Custom command example: Login', email, password);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "<%= tsConfigPath %>",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"allowJs": true,
|
|
5
|
+
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
|
6
|
+
"module": "commonjs",
|
|
7
|
+
"types": ["cypress", "node"],
|
|
8
|
+
"sourceMap": false
|
|
9
|
+
},
|
|
10
|
+
"include": [
|
|
11
|
+
"**/*.ts",
|
|
12
|
+
"**/*.js",
|
|
13
|
+
"<%= offsetFromProjectRoot %>cypress.config.ts",
|
|
14
|
+
"<%= offsetFromProjectRoot %>**/*.cy.ts",
|
|
15
|
+
"<%= offsetFromProjectRoot %>**/*.cy.tsx",
|
|
16
|
+
"<%= offsetFromProjectRoot %>**/*.cy.js",
|
|
17
|
+
"<%= offsetFromProjectRoot %>**/*.cy.jsx",
|
|
18
|
+
"<%= offsetFromProjectRoot %>**/*.d.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -2,3 +2,4 @@ import { ProjectConfiguration, Tree } from '@nx/devkit';
|
|
|
2
2
|
import { CypressComponentConfigurationSchema } from './schema';
|
|
3
3
|
export declare function cypressComponentConfiguration(tree: Tree, options: CypressComponentConfigurationSchema): Promise<() => void>;
|
|
4
4
|
export declare function updateTsConfigForComponentTesting(tree: Tree, projectConfig: ProjectConfiguration): void;
|
|
5
|
+
export default cypressComponentConfiguration;
|
|
@@ -5,19 +5,17 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
6
|
const cypress_version_1 = require("../../utils/cypress-version");
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
|
+
const base_setup_1 = require("../base-setup/base-setup");
|
|
8
9
|
function cypressComponentConfiguration(tree, options) {
|
|
9
10
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const installDepsTask = updateDeps(tree, options);
|
|
16
|
-
addProjectFiles(tree, projectConfig, options);
|
|
17
|
-
addTargetToProject(tree, projectConfig, options);
|
|
11
|
+
const opts = normalizeOptions(options);
|
|
12
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, opts.project);
|
|
13
|
+
const installDepsTask = updateDeps(tree, opts);
|
|
14
|
+
addProjectFiles(tree, projectConfig, opts);
|
|
15
|
+
addTargetToProject(tree, projectConfig, opts);
|
|
18
16
|
updateNxJsonConfiguration(tree);
|
|
19
17
|
updateTsConfigForComponentTesting(tree, projectConfig);
|
|
20
|
-
if (!
|
|
18
|
+
if (!opts.skipFormat) {
|
|
21
19
|
yield (0, devkit_1.formatFiles)(tree);
|
|
22
20
|
}
|
|
23
21
|
return () => {
|
|
@@ -26,11 +24,19 @@ function cypressComponentConfiguration(tree, options) {
|
|
|
26
24
|
});
|
|
27
25
|
}
|
|
28
26
|
exports.cypressComponentConfiguration = cypressComponentConfiguration;
|
|
29
|
-
function
|
|
27
|
+
function normalizeOptions(options) {
|
|
28
|
+
var _a;
|
|
29
|
+
const cyVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
30
|
+
if (cyVersion && cyVersion < 10) {
|
|
31
|
+
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');
|
|
32
|
+
}
|
|
33
|
+
return Object.assign(Object.assign({}, options), { directory: (_a = options.directory) !== null && _a !== void 0 ? _a : 'cypress' });
|
|
34
|
+
}
|
|
35
|
+
function updateDeps(tree, opts) {
|
|
30
36
|
const devDeps = {
|
|
31
37
|
cypress: versions_1.cypressVersion,
|
|
32
38
|
};
|
|
33
|
-
if (
|
|
39
|
+
if (opts.bundler === 'vite') {
|
|
34
40
|
devDeps['@cypress/vite-dev-server'] = versions_1.cypressViteDevServerVersion;
|
|
35
41
|
}
|
|
36
42
|
else {
|
|
@@ -39,10 +45,14 @@ function updateDeps(tree, options) {
|
|
|
39
45
|
}
|
|
40
46
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, devDeps);
|
|
41
47
|
}
|
|
42
|
-
function addProjectFiles(tree, projectConfig,
|
|
43
|
-
(0,
|
|
48
|
+
function addProjectFiles(tree, projectConfig, opts) {
|
|
49
|
+
(0, base_setup_1.addBaseCypressSetup)(tree, {
|
|
50
|
+
project: opts.project,
|
|
51
|
+
directory: opts.directory,
|
|
52
|
+
});
|
|
53
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), projectConfig.root, Object.assign(Object.assign({}, opts), { projectRoot: projectConfig.root, offsetFromRoot: (0, devkit_1.offsetFromRoot)(projectConfig.root), ext: '' }));
|
|
44
54
|
}
|
|
45
|
-
function addTargetToProject(tree, projectConfig,
|
|
55
|
+
function addTargetToProject(tree, projectConfig, opts) {
|
|
46
56
|
projectConfig.targets['component-test'] = {
|
|
47
57
|
executor: '@nx/cypress:cypress',
|
|
48
58
|
options: {
|
|
@@ -50,7 +60,7 @@ function addTargetToProject(tree, projectConfig, options) {
|
|
|
50
60
|
testingType: 'component',
|
|
51
61
|
},
|
|
52
62
|
};
|
|
53
|
-
(0, devkit_1.updateProjectConfiguration)(tree,
|
|
63
|
+
(0, devkit_1.updateProjectConfiguration)(tree, opts.project, projectConfig);
|
|
54
64
|
}
|
|
55
65
|
function updateNxJsonConfiguration(tree) {
|
|
56
66
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -102,9 +112,9 @@ function updateTsConfigForComponentTesting(tree, projectConfig) {
|
|
|
102
112
|
if (tree.exists(projectBaseTsConfig)) {
|
|
103
113
|
(0, devkit_1.updateJson)(tree, projectBaseTsConfig, (json) => {
|
|
104
114
|
if (json.references) {
|
|
105
|
-
const hasCyTsConfig = json.references.some((r) => r.path
|
|
115
|
+
const hasCyTsConfig = json.references.some((r) => r.path.includes('./cypress/tsconfig.json'));
|
|
106
116
|
if (!hasCyTsConfig) {
|
|
107
|
-
json.references.push({ path: './cypress/tsconfig.
|
|
117
|
+
json.references.push({ path: './cypress/tsconfig.json' });
|
|
108
118
|
}
|
|
109
119
|
}
|
|
110
120
|
else {
|
|
@@ -124,4 +134,5 @@ function updateTsConfigForComponentTesting(tree, projectConfig) {
|
|
|
124
134
|
}
|
|
125
135
|
}
|
|
126
136
|
exports.updateTsConfigForComponentTesting = updateTsConfigForComponentTesting;
|
|
137
|
+
exports.default = cypressComponentConfiguration;
|
|
127
138
|
//# sourceMappingURL=cypress-component-configuration.js.map
|
package/src/generators/cypress-component-configuration/cypress-component-configuration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cypress-component-configuration.js","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration.ts"],"names":[],"mappings":";;;;AAAA,uCAaoB;AACpB,iEAAsE;AAEtE,mDAK8B;
|
|
1
|
+
{"version":3,"file":"cypress-component-configuration.js","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration.ts"],"names":[],"mappings":";;;;AAAA,uCAaoB;AACpB,iEAAsE;AAEtE,mDAK8B;AAE9B,yDAA+D;AAI/D,SAAsB,6BAA6B,CACjD,IAAU,EACV,OAA4C;;QAE5C,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAEvC,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAEnE,MAAM,eAAe,GAAG,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE/C,eAAe,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;QAC3C,kBAAk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CAAC,CAAC;YAEH,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACpC,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;KACJ;IAED,MAAM,mBAAmB,GAAG,IAAA,0BAAiB,EAC3C,aAAa,CAAC,IAAI,EAClB,eAAe,CAChB,CAAC;IACF,IAAI,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE;QACpC,IAAA,mBAAU,EAAC,IAAI,EAAE,mBAAmB,EAAE,CAAC,IAAI,EAAE,EAAE;YAC7C,IAAI,IAAI,CAAC,UAAU,EAAE;gBACnB,MAAM,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/C,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAC3C,CAAC;gBACF,IAAI,CAAC,aAAa,EAAE;oBAClB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,yBAAyB,EAAE,CAAC,CAAC;iBAC3D;aACF;iBAAM;gBACL,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC;oBACvB,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;oBACvB,cAAc;oBACd,mBAAmB;oBACnB,YAAY;oBACZ,YAAY;oBACZ,aAAa;oBACb,aAAa;iBACd,CAAC,CAAC;gBAEH,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aACrC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AAzDD,8EAyDC;AAED,kBAAe,6BAA6B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// ***********************************************************
|
|
2
|
-
// This example support/
|
|
2
|
+
// This example support/component.ts is processed and
|
|
3
3
|
// loaded automatically before your test files.
|
|
4
4
|
//
|
|
5
5
|
// This is a great place to put global configuration and
|
|
@@ -13,5 +13,15 @@
|
|
|
13
13
|
// https://on.cypress.io/configuration
|
|
14
14
|
// ***********************************************************
|
|
15
15
|
|
|
16
|
-
// Import commands.
|
|
16
|
+
// Import commands.ts using ES2015 syntax:
|
|
17
17
|
import './commands';
|
|
18
|
+
|
|
19
|
+
// add component testing only related command here, such as mount
|
|
20
|
+
declare global {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
22
|
+
namespace Cypress {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
+
interface Chainable<Subject> {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"type": "object",
|
|
8
8
|
"examples": [
|
|
9
9
|
{
|
|
10
|
-
"command": "nx g @
|
|
10
|
+
"command": "nx g @nx/cypress:cypress-component-configuration --project=my-cool-lib ",
|
|
11
11
|
"description": "Add cypress component testing to an existing project named my-cool-lib"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"enum": ["vite", "webpack"],
|
|
27
27
|
"x-prompt": "Which Cypress bundler do you want to use for the dev-server?",
|
|
28
28
|
"default": "webpack"
|
|
29
|
+
},
|
|
30
|
+
"directory": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"description": "A directory where the project is placed relative from the project root",
|
|
33
|
+
"default": "cypress"
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
"required": ["project"],
|
|
@@ -7,9 +7,11 @@ const js_1 = require("@nx/js");
|
|
|
7
7
|
const linter_1 = require("@nx/linter");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const add_linter_1 = require("../../utils/add-linter");
|
|
10
|
+
const config_1 = require("../../utils/config");
|
|
10
11
|
const cypress_version_1 = require("../../utils/cypress-version");
|
|
11
12
|
const versions_1 = require("../../utils/versions");
|
|
12
13
|
const init_1 = require("../init/init");
|
|
14
|
+
const base_setup_1 = require("../base-setup/base-setup");
|
|
13
15
|
function cypressE2EConfigurationGenerator(tree, options) {
|
|
14
16
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
17
|
const opts = normalizeOptions(tree, options);
|
|
@@ -20,7 +22,7 @@ function cypressE2EConfigurationGenerator(tree, options) {
|
|
|
20
22
|
if (opts.bundler === 'vite') {
|
|
21
23
|
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { vite: versions_1.viteVersion }));
|
|
22
24
|
}
|
|
23
|
-
addFiles(tree, opts);
|
|
25
|
+
yield addFiles(tree, opts);
|
|
24
26
|
addTarget(tree, opts);
|
|
25
27
|
(0, add_linter_1.addLinterToCyProject)(tree, Object.assign(Object.assign({}, opts), { cypressDir: opts.directory }));
|
|
26
28
|
if (!opts.skipFormat) {
|
|
@@ -44,55 +46,53 @@ Rename or remove the existing e2e target.`);
|
|
|
44
46
|
In this case you need to provide a devServerTarget,'<projectName>:<targetName>[:<configName>]', or a baseUrl option`);
|
|
45
47
|
}
|
|
46
48
|
(_b = options.directory) !== null && _b !== void 0 ? _b : (options.directory = 'src');
|
|
47
|
-
if (tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, options.directory))) {
|
|
48
|
-
throw new Error(`The project, ${options.project}, already has a '${options.directory}' directory.
|
|
49
|
-
This most likely means you already have Cypress setup in this project.
|
|
50
|
-
Make sure Cypress is not already setup in this project and try again.`);
|
|
51
|
-
}
|
|
52
|
-
const cyVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
53
|
-
const cyFile = cyVersion && cyVersion < 10 ? 'cypress.json' : 'cypress.config.ts';
|
|
54
|
-
if (tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, cyFile))) {
|
|
55
|
-
throw new Error(`The project, ${options.project}, already has a '${cyFile}' file.
|
|
56
|
-
This means that Cypress is already setup in this project.
|
|
57
|
-
If you want to re-add Cypress to this project, remove the '${(0, devkit_1.joinPathFragments)(projectConfig.root, cyFile)}' file and try again.`);
|
|
58
|
-
}
|
|
59
49
|
return Object.assign(Object.assign({}, options), { bundler: (_c = options.bundler) !== null && _c !== void 0 ? _c : 'webpack', rootProject: projectConfig.root === '.', linter: (_d = options.linter) !== null && _d !== void 0 ? _d : linter_1.Linter.EsLint, devServerTarget: (_e = options.devServerTarget) !== null && _e !== void 0 ? _e : (projectConfig.targets.serve ? `${options.project}:serve` : undefined) });
|
|
60
50
|
}
|
|
61
51
|
function addFiles(tree, options) {
|
|
62
52
|
var _a;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
53
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
55
|
+
const cyVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
56
|
+
const filesToUse = cyVersion && cyVersion < 10 ? 'v9' : 'v10';
|
|
57
|
+
const hasTsConfig = tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'));
|
|
58
|
+
const offsetFromProjectRoot = options.directory
|
|
59
|
+
.split('/')
|
|
60
|
+
.map((_) => '..')
|
|
61
|
+
.join('/');
|
|
62
|
+
const fileOpts = Object.assign(Object.assign({}, options), { dir: (_a = options.directory) !== null && _a !== void 0 ? _a : 'src', ext: options.js ? 'js' : 'ts', offsetFromRoot: (0, devkit_1.offsetFromRoot)(projectConfig.root), offsetFromProjectRoot, tsConfigPath: hasTsConfig
|
|
63
|
+
? `${offsetFromProjectRoot}/tsconfig.json`
|
|
64
|
+
: (0, js_1.getRelativePathToRootTsConfig)(tree, projectConfig.root), tmpl: '' });
|
|
65
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', filesToUse), projectConfig.root, fileOpts);
|
|
66
|
+
if (filesToUse === 'v10') {
|
|
67
|
+
(0, base_setup_1.addBaseCypressSetup)(tree, {
|
|
68
|
+
project: options.project,
|
|
69
|
+
directory: options.directory,
|
|
77
70
|
});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return json;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
else if (cyVersion < 10) {
|
|
88
|
-
const pluginPath = (0, path_1.join)(projectConfig.root, 'src/plugins/index.js');
|
|
89
|
-
if (tree.exists(pluginPath)) {
|
|
90
|
-
tree.delete(pluginPath);
|
|
71
|
+
const cyFile = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.ts');
|
|
72
|
+
const updatedCyConfig = yield (0, config_1.addDefaultE2EConfig)(tree.read(cyFile, 'utf-8'), {
|
|
73
|
+
directory: options.directory,
|
|
74
|
+
bundler: options.bundler,
|
|
75
|
+
});
|
|
76
|
+
tree.write(cyFile, updatedCyConfig);
|
|
91
77
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
78
|
+
if (cyVersion &&
|
|
79
|
+
cyVersion < 7 &&
|
|
80
|
+
tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'src', 'plugins', 'index.js'))) {
|
|
81
|
+
(0, devkit_1.updateJson)(tree, (0, path_1.join)(projectConfig.root, 'cypress.json'), (json) => {
|
|
82
|
+
json.pluginsFile = './src/plugins/index';
|
|
83
|
+
return json;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else if (cyVersion < 10) {
|
|
87
|
+
const pluginPath = (0, path_1.join)(projectConfig.root, 'src/plugins/index.js');
|
|
88
|
+
if (tree.exists(pluginPath)) {
|
|
89
|
+
tree.delete(pluginPath);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (options.js) {
|
|
93
|
+
(0, devkit_1.toJS)(tree);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
96
|
}
|
|
97
97
|
function addTarget(tree, opts) {
|
|
98
98
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cypress-e2e-configuration.js","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.ts"],"names":[],"mappings":";;;;AAAA,uCAeoB;AACpB,+BAAuD;AACvD,uCAAoC;AACpC,+BAA4B;AAC5B,uDAA8D;AAC9D,iEAAsE;AACtE,mDAAmD;AACnD,uCAAgD;
|
|
1
|
+
{"version":3,"file":"cypress-e2e-configuration.js","sourceRoot":"","sources":["../../../../../../packages/cypress/src/generators/cypress-e2e-configuration/cypress-e2e-configuration.ts"],"names":[],"mappings":";;;;AAAA,uCAeoB;AACpB,+BAAuD;AACvD,uCAAoC;AACpC,+BAA4B;AAC5B,uDAA8D;AAC9D,+CAAyD;AACzD,iEAAsE;AACtE,mDAAmD;AACnD,uCAAgD;AAChD,yDAA+D;AAiB/D,SAAsB,gCAAgC,CACpD,IAAU,EACV,OAA+B;;QAE/B,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE7C,MAAM,KAAK,GAAwB,EAAE,CAAC;QAEtC,IAAI,CAAC,IAAA,yCAAuB,GAAE,EAAE;YAC9B,KAAK,CAAC,IAAI,CAAC,MAAM,IAAA,cAAoB,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;SACpD;QACD,IAAI,IAAI,CAAC,OAAO,KAAK,MAAM,EAAE;YAC3B,KAAK,CAAC,IAAI,CAAC,IAAA,qCAA4B,EAAC,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,sBAAW,EAAE,CAAC,CAAC,CAAC;SAC3E;QACD,MAAM,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC3B,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACtB,IAAA,iCAAoB,EAAC,IAAI,kCACpB,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AAc,CAAC,EAAE,GAAG;gBAC5C,eAAe,EAAE,GAAG,YAAY,CAAC,OAAO,eAAe;aACxD,CAAC;SACH;KACF;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;KACvE;IAED,IAAA,mCAA0B,EAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AAChE,CAAC;AAED,kBAAe,gCAAgC,CAAC;AACnC,QAAA,MAAM,GAAG,IAAA,2BAAkB,EAAC,gCAAgC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// ***********************************************************
|
|
2
|
-
// This example support/
|
|
2
|
+
// This example support/e2e.ts is processed and
|
|
3
3
|
// loaded automatically before your test files.
|
|
4
4
|
//
|
|
5
5
|
// This is a great place to put global configuration and
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeCyTsConfigNames = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
7
|
+
function normalizeCyTsConfigNames(tree) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
10
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/cypress:cypress', (_, projectName) => {
|
|
11
|
+
const projectConfig = projects.get(projectName);
|
|
12
|
+
const newTsConfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'tsconfig.json');
|
|
13
|
+
// if there is already a tsconfig.json in the cypress folder, then assume things are setup already
|
|
14
|
+
if (!tree.exists(newTsConfigPath)) {
|
|
15
|
+
moveProjectTsCyConfig(tree, projectConfig, newTsConfigPath);
|
|
16
|
+
moveCyDirTsCyConfig(tree, projectConfig, newTsConfigPath);
|
|
17
|
+
updateCyDirTsConfigReferences(tree, projectConfig);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
exports.normalizeCyTsConfigNames = normalizeCyTsConfigNames;
|
|
24
|
+
function moveProjectTsCyConfig(tree, projectConfig, newTsConfigPath) {
|
|
25
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.cy.json'))) {
|
|
26
|
+
tree.rename((0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.cy.json'), newTsConfigPath);
|
|
27
|
+
(0, devkit_1.updateJson)(tree, newTsConfigPath, (json) => {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
json.extends = '../tsconfig.json';
|
|
30
|
+
(_a = json.compilerOptions) !== null && _a !== void 0 ? _a : (json.compilerOptions = {});
|
|
31
|
+
json.compilerOptions = Object.assign(Object.assign({}, json.compilerOptions), { sourceMap: false, outDir: '../../../dist/out-tsc' });
|
|
32
|
+
(_b = json.include) !== null && _b !== void 0 ? _b : (json.include = []);
|
|
33
|
+
json.include = json.include.map((p) => {
|
|
34
|
+
if (p.startsWith('cypress/')) {
|
|
35
|
+
return p.replace('cypress/', '');
|
|
36
|
+
}
|
|
37
|
+
return `../${p}`;
|
|
38
|
+
});
|
|
39
|
+
return json;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function moveCyDirTsCyConfig(tree, projectConfig, newTsConfigPath) {
|
|
44
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'tsconfig.cy.json'))) {
|
|
45
|
+
tree.rename((0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress', 'tsconfig.cy.json'), newTsConfigPath);
|
|
46
|
+
(0, devkit_1.updateJson)(tree, newTsConfigPath, (json) => {
|
|
47
|
+
var _a;
|
|
48
|
+
(_a = json.compilerOptions) !== null && _a !== void 0 ? _a : (json.compilerOptions = {});
|
|
49
|
+
json.compilerOptions = Object.assign(Object.assign({}, json.compilerOptions), { sourceMap: false });
|
|
50
|
+
return json;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function updateCyDirTsConfigReferences(tree, projectConfig) {
|
|
55
|
+
if (!tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress'))) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'), (json) => {
|
|
59
|
+
var _a;
|
|
60
|
+
(_a = json.references) !== null && _a !== void 0 ? _a : (json.references = []);
|
|
61
|
+
if (!json.references) {
|
|
62
|
+
return json;
|
|
63
|
+
}
|
|
64
|
+
const cyFile = json.references.find((p) => p.path.includes('tsconfig.cy.json'));
|
|
65
|
+
if (cyFile) {
|
|
66
|
+
json.references.splice(json.references.indexOf(cyFile), 1);
|
|
67
|
+
}
|
|
68
|
+
if (!json.references.some((r) => r.path === './cypress/tsconfig.json')) {
|
|
69
|
+
json.references.push({
|
|
70
|
+
path: './cypress/tsconfig.json',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return json;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.default = normalizeCyTsConfigNames;
|
|
77
|
+
//# sourceMappingURL=update-cy-tsconfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-cy-tsconfig.js","sourceRoot":"","sources":["../../../../../../packages/cypress/src/migrations/update-16-2-0/update-cy-tsconfig.ts"],"names":[],"mappings":";;;;AAAA,uCAOoB;AACpB,6FAA0F;AAE1F,SAAsB,wBAAwB,CAAC,IAAU;;QACvD,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAEnC,IAAA,+CAAsB,EAAC,IAAI,EAAE,qBAAqB,EAAE,CAAC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IAAI,CAAC,UAAU,oCAAf,IAAI,CAAC,UAAU,GAAK,EAAE,EAAC;QACvB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,OAAO,IAAI,CAAC;SACb;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CACxC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CACpC,CAAC;QAEF,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;SAC5D;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,yBAAyB,CAAC,EAAE;YACtE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;gBACnB,IAAI,EAAE,yBAAyB;aAChC,CAAC,CAAC;SACJ;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CACF,CAAC;AACJ,CAAC;AAED,kBAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function addDefaultE2EConfig(cyConfigContents: string, options: {
|
|
2
|
+
directory: string;
|
|
3
|
+
bundler?: string;
|
|
4
|
+
}): Promise<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Adds the nxComponentTestingPreset to the cypress config file
|
|
7
|
+
* Make sure after calling this the correct import statement is addeda
|
|
8
|
+
* to bring in the nxComponentTestingPreset function
|
|
9
|
+
**/
|
|
10
|
+
export declare function addDefaultCTConfig(cyConfigContents: string, options?: {
|
|
11
|
+
bundler?: string;
|
|
12
|
+
}): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Adds the mount command for Cypress
|
|
15
|
+
* Make sure after calling this the correct import statement is added
|
|
16
|
+
* to bring in the correct mount from cypress.
|
|
17
|
+
**/
|
|
18
|
+
export declare function addMountDefinition(cmpCommandFileContents: string): Promise<string>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addMountDefinition = exports.addDefaultCTConfig = exports.addDefaultE2EConfig = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const TS_QUERY_EXPORT_CONFIG_PREFIX = ':matches(ExportAssignment, BinaryExpression:has(Identifier[name="module"]):has(Identifier[name="exports"]))';
|
|
6
|
+
function addDefaultE2EConfig(cyConfigContents, options) {
|
|
7
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
8
|
+
if (!cyConfigContents) {
|
|
9
|
+
throw new Error('The passed in cypress config file is empty!');
|
|
10
|
+
}
|
|
11
|
+
const { tsquery } = yield Promise.resolve().then(() => require('@phenomnomnominal/tsquery'));
|
|
12
|
+
const testingTypeConfig = tsquery.query(cyConfigContents, `${TS_QUERY_EXPORT_CONFIG_PREFIX} PropertyAssignment:has(Identifier[name="e2e"])`);
|
|
13
|
+
let updatedConfigContents = cyConfigContents;
|
|
14
|
+
if (testingTypeConfig.length === 0) {
|
|
15
|
+
const configValue = options.bundler === 'vite'
|
|
16
|
+
? `nxE2EPreset(__filename, { cypressDir: '${options.directory}', bundler: 'vite' })`
|
|
17
|
+
: `nxE2EPreset(__filename, { cypressDir: '${options.directory}' })`;
|
|
18
|
+
updatedConfigContents = tsquery.replace(cyConfigContents, `${TS_QUERY_EXPORT_CONFIG_PREFIX} ObjectLiteralExpression:first-child`, (node) => {
|
|
19
|
+
if (node.properties.length > 0) {
|
|
20
|
+
return `{
|
|
21
|
+
${node.properties.map((p) => p.getText()).join(',\n')},
|
|
22
|
+
e2e: ${configValue}
|
|
23
|
+
}`;
|
|
24
|
+
}
|
|
25
|
+
return `{
|
|
26
|
+
e2e: ${configValue}
|
|
27
|
+
}`;
|
|
28
|
+
});
|
|
29
|
+
updatedConfigContents = `import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';\n${updatedConfigContents}`;
|
|
30
|
+
}
|
|
31
|
+
return updatedConfigContents;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
exports.addDefaultE2EConfig = addDefaultE2EConfig;
|
|
35
|
+
/**
|
|
36
|
+
* Adds the nxComponentTestingPreset to the cypress config file
|
|
37
|
+
* Make sure after calling this the correct import statement is addeda
|
|
38
|
+
* to bring in the nxComponentTestingPreset function
|
|
39
|
+
**/
|
|
40
|
+
function addDefaultCTConfig(cyConfigContents, options = {}) {
|
|
41
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
if (!cyConfigContents) {
|
|
43
|
+
throw new Error('The passed in cypress config file is empty!');
|
|
44
|
+
}
|
|
45
|
+
const { tsquery } = yield Promise.resolve().then(() => require('@phenomnomnominal/tsquery'));
|
|
46
|
+
const testingTypeConfig = tsquery.query(cyConfigContents, `${TS_QUERY_EXPORT_CONFIG_PREFIX} PropertyAssignment:has(Identifier[name="component"])`);
|
|
47
|
+
let updatedConfigContents = cyConfigContents;
|
|
48
|
+
if (testingTypeConfig.length === 0) {
|
|
49
|
+
const configValue = (options === null || options === void 0 ? void 0 : options.bundler) === 'vite'
|
|
50
|
+
? "nxComponentTestingPreset(__filename, { bundler: 'vite' })"
|
|
51
|
+
: 'nxComponentTestingPreset(__filename)';
|
|
52
|
+
updatedConfigContents = tsquery.replace(cyConfigContents, `${TS_QUERY_EXPORT_CONFIG_PREFIX} ObjectLiteralExpression:first-child`, (node) => {
|
|
53
|
+
if (node.properties.length > 0) {
|
|
54
|
+
return `{
|
|
55
|
+
${node.properties.map((p) => p.getText()).join(',\n')},
|
|
56
|
+
component: ${configValue}
|
|
57
|
+
}`;
|
|
58
|
+
}
|
|
59
|
+
return `{
|
|
60
|
+
component: ${configValue}
|
|
61
|
+
}`;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return updatedConfigContents;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
exports.addDefaultCTConfig = addDefaultCTConfig;
|
|
68
|
+
/**
|
|
69
|
+
* Adds the mount command for Cypress
|
|
70
|
+
* Make sure after calling this the correct import statement is added
|
|
71
|
+
* to bring in the correct mount from cypress.
|
|
72
|
+
**/
|
|
73
|
+
function addMountDefinition(cmpCommandFileContents) {
|
|
74
|
+
var _a;
|
|
75
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
if (!cmpCommandFileContents) {
|
|
77
|
+
throw new Error('The passed in cypress component file is empty!');
|
|
78
|
+
}
|
|
79
|
+
const { tsquery } = yield Promise.resolve().then(() => require('@phenomnomnominal/tsquery'));
|
|
80
|
+
const hasMountCommand = ((_a = tsquery.query(cmpCommandFileContents, 'CallExpression StringLiteral[value="mount"]')) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
81
|
+
if (hasMountCommand) {
|
|
82
|
+
return cmpCommandFileContents;
|
|
83
|
+
}
|
|
84
|
+
const mountCommand = `Cypress.Commands.add('mount', mount);`;
|
|
85
|
+
const updatedInterface = tsquery.replace(cmpCommandFileContents, 'InterfaceDeclaration', (node) => {
|
|
86
|
+
return `interface ${node.name.getText()}${node.typeParameters
|
|
87
|
+
? `<${node.typeParameters.map((p) => p.getText()).join(', ')}>`
|
|
88
|
+
: ''} {
|
|
89
|
+
${node.members.map((m) => m.getText()).join('\n ')}
|
|
90
|
+
mount: typeof mount;
|
|
91
|
+
}`;
|
|
92
|
+
});
|
|
93
|
+
return `${updatedInterface}\n${mountCommand}`;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.addMountDefinition = addMountDefinition;
|
|
97
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../../packages/cypress/src/utils/config.ts"],"names":[],"mappings":";;;;AASA,MAAM,6BAA6B,GACjC,6GAA6G,CAAC;AAEhH,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YACnB,OAAO,sBAAsB,CAAC;SAC/B;QAED,MAAM,YAAY,GAAG,uCAAuC,CAAC;QAE7D,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CACtC,sBAAsB,EACtB,sBAAsB,EACtB,CAAC,IAA0B,EAAE,EAAE;YAC7B,OAAO,aAAa,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GACrC,IAAI,CAAC,cAAc;gBACjB,CAAC,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;gBAC/D,CAAC,CAAC,EACN;QACE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;;MAEvD,CAAC;QACH,CAAC,CACF,CAAC;QACF,OAAO,GAAG,gBAAgB,KAAK,YAAY,EAAE,CAAC;;CAC/C;AAhCD,gDAgCC"}
|
package/src/generators/cypress-component-configuration/files/cypress/support/commands.ts__ext__
DELETED
|
@@ -1,42 +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
|
-
declare global {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
15
|
-
namespace Cypress {
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
|
-
interface Chainable<Subject> {
|
|
18
|
-
login(email: string, password: string): void;
|
|
19
|
-
// TODO: define a mount command
|
|
20
|
-
// mount: typeof mount;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Cypress.Commands.add('mount', mount)
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
// -- This is a parent command --
|
|
29
|
-
Cypress.Commands.add('login', (email, password) => {
|
|
30
|
-
console.log('Custom command example: Login', email, password);
|
|
31
|
-
});
|
|
32
|
-
//
|
|
33
|
-
// -- This is a child command --
|
|
34
|
-
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
// -- This is a dual command --
|
|
38
|
-
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
// -- This will overwrite an existing command --
|
|
42
|
-
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
|
5
|
-
"module": "commonjs",
|
|
6
|
-
"types": ["cypress", "node"]
|
|
7
|
-
},
|
|
8
|
-
"include": [
|
|
9
|
-
"support/**/*.ts",
|
|
10
|
-
"../cypress.config.ts",
|
|
11
|
-
"../**/*.cy.ts",
|
|
12
|
-
"../**/*.cy.tsx",
|
|
13
|
-
"../**/*.cy.js",
|
|
14
|
-
"../**/*.cy.jsx",
|
|
15
|
-
"../**/*.d.ts"
|
|
16
|
-
]
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'cypress';
|
|
2
|
-
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
|
|
3
|
-
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
e2e: nxE2EPreset(__dirname, {
|
|
6
|
-
cypressDir: "<%= dir %>",
|
|
7
|
-
<% if (bundler === 'vite'){ %>bundler: 'vite',<% } %>
|
|
8
|
-
})
|
|
9
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "<%= tsConfigPath %>",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"sourceMap": false,
|
|
5
|
-
"outDir": "<%= offsetFromRoot %>dist/out-tsc",
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"types": ["cypress", "node"]
|
|
8
|
-
},
|
|
9
|
-
"include": ["<%= dir %>/**/*.ts", "<%= dir %>/**/*.js", "cypress.config.ts"]
|
|
10
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|