@nx/cypress 0.0.0-pr-22179-271588f
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 +22 -0
- package/README.md +68 -0
- package/executors.json +9 -0
- package/generators.json +37 -0
- package/index.d.ts +11 -0
- package/index.js +20 -0
- package/migrations.json +111 -0
- package/package.json +58 -0
- package/plugin.d.ts +1 -0
- package/plugin.js +6 -0
- package/plugins/cypress-preset.d.ts +69 -0
- package/plugins/cypress-preset.js +154 -0
- package/src/executors/cypress/cypress.impl.d.ts +40 -0
- package/src/executors/cypress/cypress.impl.js +182 -0
- package/src/executors/cypress/schema.json +186 -0
- package/src/generators/base-setup/base-setup.d.ts +12 -0
- package/src/generators/base-setup/base-setup.js +80 -0
- package/src/generators/base-setup/files/common/__directory__/fixtures/example.json +5 -0
- package/src/generators/base-setup/files/common/__directory__/support/commands.ts__ext__ +35 -0
- package/src/generators/base-setup/files/common/__directory__/tsconfig.json__ext__ +20 -0
- package/src/generators/base-setup/files/config-js-cjs/__directory__/support/commands.js__ext__ +35 -0
- package/src/generators/base-setup/files/config-js-cjs/cypress.config.js__ext__ +3 -0
- package/src/generators/base-setup/files/config-js-esm/__directory__/support/commands.js__ext__ +35 -0
- package/src/generators/base-setup/files/config-js-esm/cypress.config.js__ext__ +3 -0
- package/src/generators/base-setup/files/config-ts/__directory__/support/commands.ts__ext__ +35 -0
- package/src/generators/base-setup/files/config-ts/cypress.config.ts__ext__ +3 -0
- package/src/generators/component-configuration/component-configuration.d.ts +6 -0
- package/src/generators/component-configuration/component-configuration.js +165 -0
- package/src/generators/component-configuration/files/__directory__/support/component-index.html +16 -0
- package/src/generators/component-configuration/files/__directory__/support/component.ts__ext__ +27 -0
- package/src/generators/component-configuration/schema.d.ts +14 -0
- package/src/generators/component-configuration/schema.json +43 -0
- package/src/generators/configuration/configuration.d.ts +23 -0
- package/src/generators/configuration/configuration.js +220 -0
- package/src/generators/configuration/files/v10/__directory__/e2e/app.cy.ts__tmpl__ +13 -0
- package/src/generators/configuration/files/v10/__directory__/support/app.po.ts__tmpl__ +1 -0
- package/src/generators/configuration/files/v10/__directory__/support/e2e.ts__tmpl__ +17 -0
- package/src/generators/configuration/files/v9/__directory__/fixtures/example.json__tmpl__ +4 -0
- package/src/generators/configuration/files/v9/__directory__/integration/app.spec.ts__tmpl__ +13 -0
- package/src/generators/configuration/files/v9/__directory__/plugins/index.js +22 -0
- package/src/generators/configuration/files/v9/__directory__/support/app.po.ts__tmpl__ +1 -0
- package/src/generators/configuration/files/v9/__directory__/support/commands.ts__tmpl__ +33 -0
- package/src/generators/configuration/files/v9/__directory__/support/index.ts__tmpl__ +17 -0
- package/src/generators/configuration/files/v9/__directory__/tsconfig.json +10 -0
- package/src/generators/configuration/files/v9/cypress.json +12 -0
- package/src/generators/configuration/schema.json +96 -0
- package/src/generators/cypress-project/cypress-project.d.ts +16 -0
- package/src/generators/cypress-project/cypress-project.js +213 -0
- package/src/generators/cypress-project/files/v10-and-after/cypress.config.ts__tmpl__ +10 -0
- package/src/generators/cypress-project/files/v10-and-after/src/e2e/app.cy.ts__tmpl__ +13 -0
- package/src/generators/cypress-project/files/v10-and-after/src/fixtures/example.json__tmpl__ +4 -0
- package/src/generators/cypress-project/files/v10-and-after/src/support/app.po.ts__tmpl__ +1 -0
- package/src/generators/cypress-project/files/v10-and-after/src/support/commands.ts__tmpl__ +33 -0
- package/src/generators/cypress-project/files/v10-and-after/src/support/e2e.ts__tmpl__ +17 -0
- package/src/generators/cypress-project/files/v10-and-after/tsconfig.json +10 -0
- package/src/generators/cypress-project/files/v9-and-under/cypress.json +12 -0
- package/src/generators/cypress-project/files/v9-and-under/src/fixtures/example.json__tmpl__ +4 -0
- package/src/generators/cypress-project/files/v9-and-under/src/integration/app.spec.ts__tmpl__ +13 -0
- package/src/generators/cypress-project/files/v9-and-under/src/plugins/index.js +22 -0
- package/src/generators/cypress-project/files/v9-and-under/src/support/app.po.ts__tmpl__ +1 -0
- package/src/generators/cypress-project/files/v9-and-under/src/support/commands.ts__tmpl__ +33 -0
- package/src/generators/cypress-project/files/v9-and-under/src/support/index.ts__tmpl__ +17 -0
- package/src/generators/cypress-project/files/v9-and-under/tsconfig.json +10 -0
- package/src/generators/cypress-project/schema.d.ts +17 -0
- package/src/generators/cypress-project/schema.json +78 -0
- package/src/generators/init/init.d.ts +6 -0
- package/src/generators/init/init.js +97 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +34 -0
- package/src/generators/migrate-to-cypress-11/conversion.util.d.ts +39 -0
- package/src/generators/migrate-to-cypress-11/conversion.util.js +246 -0
- package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.d.ts +3 -0
- package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.js +93 -0
- package/src/generators/migrate-to-cypress-11/schema.json +15 -0
- package/src/migrations/update-15-0-0/add-cypress-inputs.d.ts +2 -0
- package/src/migrations/update-15-0-0/add-cypress-inputs.js +42 -0
- package/src/migrations/update-15-0-0/update-cy-mount-usage.d.ts +5 -0
- package/src/migrations/update-15-0-0/update-cy-mount-usage.js +119 -0
- package/src/migrations/update-15-1-0/cypress-11.d.ts +6 -0
- package/src/migrations/update-15-1-0/cypress-11.js +114 -0
- package/src/migrations/update-15-5-0/helpers.d.ts +3 -0
- package/src/migrations/update-15-5-0/helpers.js +39 -0
- package/src/migrations/update-15-5-0/update-to-cypress-12.d.ts +24 -0
- package/src/migrations/update-15-5-0/update-to-cypress-12.js +180 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- 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-4-0/tsconfig-sourcemaps.d.ts +3 -0
- package/src/migrations/update-16-4-0/tsconfig-sourcemaps.js +62 -0
- package/src/migrations/update-16-8-0/cypress-13.d.ts +7 -0
- package/src/migrations/update-16-8-0/cypress-13.js +179 -0
- package/src/migrations/update-18-1-0/update-cypress-version-13-6-6.d.ts +2 -0
- package/src/migrations/update-18-1-0/update-cypress-version-13-6-6.js +12 -0
- package/src/plugins/plugin.d.ts +8 -0
- package/src/plugins/plugin.js +195 -0
- package/src/plugins/preprocessor-vite.d.ts +32 -0
- package/src/plugins/preprocessor-vite.js +97 -0
- package/src/utils/add-linter.d.ts +22 -0
- package/src/utils/add-linter.js +93 -0
- package/src/utils/config.d.ts +17 -0
- package/src/utils/config.js +115 -0
- package/src/utils/constants.d.ts +4 -0
- package/src/utils/constants.js +7 -0
- package/src/utils/ct-helpers.d.ts +16 -0
- package/src/utils/ct-helpers.js +86 -0
- package/src/utils/cypress-version.d.ts +5 -0
- package/src/utils/cypress-version.js +33 -0
- package/src/utils/find-target-options.d.ts +17 -0
- package/src/utils/find-target-options.js +136 -0
- package/src/utils/project-name.d.ts +3 -0
- package/src/utils/project-name.js +19 -0
- package/src/utils/start-dev-server.d.ts +9 -0
- package/src/utils/start-dev-server.js +157 -0
- package/src/utils/versions.d.ts +9 -0
- package/src/utils/versions.js +12 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const ct_helpers_1 = require("../../utils/ct-helpers");
|
|
7
|
+
const cypress_version_1 = require("../../utils/cypress-version");
|
|
8
|
+
const start_dev_server_1 = require("../../utils/start-dev-server");
|
|
9
|
+
const Cypress = require('cypress'); // @NOTE: Importing via ES6 messes the whole test dependencies.
|
|
10
|
+
async function cypressExecutor(options, context) {
|
|
11
|
+
options = normalizeOptions(options, context);
|
|
12
|
+
// this is used by cypress component testing presets to build the executor contexts with the correct configuration options.
|
|
13
|
+
process.env.NX_CYPRESS_TARGET_CONFIGURATION = context.configurationName;
|
|
14
|
+
let success;
|
|
15
|
+
for await (const devServerValues of (0, start_dev_server_1.startDevServer)(options, context)) {
|
|
16
|
+
try {
|
|
17
|
+
success = await runCypress(devServerValues.baseUrl, {
|
|
18
|
+
...options,
|
|
19
|
+
portLockFilePath: devServerValues.portLockFilePath,
|
|
20
|
+
});
|
|
21
|
+
if (!options.watch)
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
devkit_1.logger.error(e.message);
|
|
26
|
+
success = false;
|
|
27
|
+
if (!options.watch)
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return { success };
|
|
32
|
+
}
|
|
33
|
+
exports.default = cypressExecutor;
|
|
34
|
+
function normalizeOptions(options, context) {
|
|
35
|
+
options.env = options.env || {};
|
|
36
|
+
if (options.testingType === 'component') {
|
|
37
|
+
const project = context?.projectGraph?.nodes?.[context.projectName];
|
|
38
|
+
if (project?.data?.root) {
|
|
39
|
+
options.ctTailwindPath = (0, ct_helpers_1.getTempTailwindPath)(context);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
checkSupportedBrowser(options);
|
|
43
|
+
warnDeprecatedHeadless(options);
|
|
44
|
+
warnDeprecatedCypressVersion();
|
|
45
|
+
return options;
|
|
46
|
+
}
|
|
47
|
+
function checkSupportedBrowser({ browser }) {
|
|
48
|
+
// Browser was not passed in as an option, cypress will use whatever default it has set and we dont need to check it
|
|
49
|
+
if (!browser) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if ((0, cypress_version_1.installedCypressVersion)() >= 4 && browser == 'canary') {
|
|
53
|
+
devkit_1.logger.warn((0, devkit_1.stripIndents) `
|
|
54
|
+
Warning:
|
|
55
|
+
You are using a browser that is not supported by cypress v4+.
|
|
56
|
+
|
|
57
|
+
Read here for more info:
|
|
58
|
+
https://docs.cypress.io/guides/references/migration-guide.html#Launching-Chrome-Canary-with-browser
|
|
59
|
+
`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const supportedV3Browsers = ['electron', 'chrome', 'canary', 'chromium'];
|
|
63
|
+
if ((0, cypress_version_1.installedCypressVersion)() <= 3 &&
|
|
64
|
+
!supportedV3Browsers.includes(browser)) {
|
|
65
|
+
devkit_1.logger.warn((0, devkit_1.stripIndents) `
|
|
66
|
+
Warning:
|
|
67
|
+
You are using a browser that is not supported by cypress v3.
|
|
68
|
+
`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function warnDeprecatedHeadless({ headless }) {
|
|
73
|
+
if ((0, cypress_version_1.installedCypressVersion)() < 8 || headless === undefined) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (headless) {
|
|
77
|
+
const deprecatedMsg = (0, devkit_1.stripIndents) `
|
|
78
|
+
NOTE:
|
|
79
|
+
You can now remove the use of the '--headless' flag during 'cypress run' as this is the default for all browsers.`;
|
|
80
|
+
devkit_1.logger.warn(deprecatedMsg);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function warnDeprecatedCypressVersion() {
|
|
84
|
+
if ((0, cypress_version_1.installedCypressVersion)() < 10) {
|
|
85
|
+
devkit_1.logger.warn((0, devkit_1.stripIndents) `
|
|
86
|
+
NOTE:
|
|
87
|
+
Support for Cypress versions < 10 is deprecated. Please upgrade to at least Cypress version 10.
|
|
88
|
+
A generator to migrate from v8 to v10 is provided. See https://nx.dev/cypress/v10-migration-guide
|
|
89
|
+
`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @whatItDoes Initialize the Cypress test runner with the provided project configuration.
|
|
94
|
+
* By default, Cypress will run tests from the CLI without the GUI and provide directly the results in the console output.
|
|
95
|
+
* If `watch` is `true`: Open Cypress in the interactive GUI to interact directly with the application.
|
|
96
|
+
*/
|
|
97
|
+
async function runCypress(baseUrl, opts) {
|
|
98
|
+
const cypressVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
99
|
+
// Cypress expects the folder where a cypress config is present
|
|
100
|
+
const projectFolderPath = (0, path_1.dirname)(opts.cypressConfig);
|
|
101
|
+
const options = {
|
|
102
|
+
project: projectFolderPath,
|
|
103
|
+
configFile: (0, path_1.basename)(opts.cypressConfig),
|
|
104
|
+
};
|
|
105
|
+
// If not, will use the `baseUrl` normally from `cypress.json`
|
|
106
|
+
if (baseUrl) {
|
|
107
|
+
options.config = { baseUrl };
|
|
108
|
+
}
|
|
109
|
+
if (opts.browser) {
|
|
110
|
+
options.browser = opts.browser;
|
|
111
|
+
}
|
|
112
|
+
if (opts.env) {
|
|
113
|
+
options.env = {
|
|
114
|
+
...options.env,
|
|
115
|
+
...opts.env,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (opts.spec) {
|
|
119
|
+
options.spec = opts.spec;
|
|
120
|
+
}
|
|
121
|
+
options.tag = opts.tag;
|
|
122
|
+
options.exit = opts.exit;
|
|
123
|
+
options.headed = opts.headed;
|
|
124
|
+
options.runnerUi = opts.runnerUi;
|
|
125
|
+
if (opts.headless) {
|
|
126
|
+
options.headless = opts.headless;
|
|
127
|
+
}
|
|
128
|
+
options.record = opts.record;
|
|
129
|
+
options.key = opts.key;
|
|
130
|
+
options.parallel = opts.parallel;
|
|
131
|
+
options.ciBuildId = opts.ciBuildId?.toString();
|
|
132
|
+
options.group = opts.group;
|
|
133
|
+
// renamed in cy 10
|
|
134
|
+
if (cypressVersion >= 10) {
|
|
135
|
+
options.config ??= {};
|
|
136
|
+
options.config[opts.testingType] = {
|
|
137
|
+
excludeSpecPattern: opts.ignoreTestFiles,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
options.ignoreTestFiles = opts.ignoreTestFiles;
|
|
142
|
+
}
|
|
143
|
+
if (opts.reporter) {
|
|
144
|
+
options.reporter = opts.reporter;
|
|
145
|
+
}
|
|
146
|
+
if (opts.reporterOptions) {
|
|
147
|
+
options.reporterOptions = opts.reporterOptions;
|
|
148
|
+
}
|
|
149
|
+
if (opts.quiet) {
|
|
150
|
+
options.quiet = opts.quiet;
|
|
151
|
+
}
|
|
152
|
+
options.testingType = opts.testingType;
|
|
153
|
+
const result = await (opts.watch
|
|
154
|
+
? Cypress.open(options)
|
|
155
|
+
: Cypress.run(options));
|
|
156
|
+
cleanupTmpFile(opts.ctTailwindPath);
|
|
157
|
+
cleanupTmpFile(opts.portLockFilePath);
|
|
158
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true' && opts.portLockFilePath) {
|
|
159
|
+
(0, fs_1.readdirSync)((0, path_1.dirname)(opts.portLockFilePath)).forEach((f) => {
|
|
160
|
+
if (f.endsWith('.txt')) {
|
|
161
|
+
devkit_1.logger.debug(`Lock file ${f} still present`);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* `cypress.open` is returning `0` and is not of the same type as `cypress.run`.
|
|
167
|
+
* `cypress.open` is the graphical UI, so it will be obvious to know what wasn't
|
|
168
|
+
* working. Forcing the build to success when `cypress.open` is used.
|
|
169
|
+
*/
|
|
170
|
+
return !result.totalFailed && !result.failures;
|
|
171
|
+
}
|
|
172
|
+
function cleanupTmpFile(path) {
|
|
173
|
+
try {
|
|
174
|
+
if (path && (0, fs_1.existsSync)(path)) {
|
|
175
|
+
(0, fs_1.unlinkSync)(path);
|
|
176
|
+
}
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"title": "Cypress Target",
|
|
4
|
+
"description": "Run Cypress for e2e, integration and component testing.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"outputCapture": "pipe",
|
|
7
|
+
"cli": "nx",
|
|
8
|
+
"presets": [
|
|
9
|
+
{
|
|
10
|
+
"name": "Starting Dev Server",
|
|
11
|
+
"keys": ["cypressConfig", "devServerTarget"]
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "Custom Base Url",
|
|
15
|
+
"keys": ["cypressConfig", "baseUrl"]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "Component Testing",
|
|
19
|
+
"keys": ["cypressConfig", "devServerTarget", "testingType", "skipServe"]
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"properties": {
|
|
23
|
+
"cypressConfig": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "The path of the Cypress configuration json file.",
|
|
26
|
+
"x-completion-type": "file",
|
|
27
|
+
"x-completion-glob": "cypress?(*)@(.js|.ts|.json)"
|
|
28
|
+
},
|
|
29
|
+
"watch": {
|
|
30
|
+
"type": "boolean",
|
|
31
|
+
"description": "Recompile and run tests when files change.",
|
|
32
|
+
"default": false
|
|
33
|
+
},
|
|
34
|
+
"tsConfig": {
|
|
35
|
+
"x-deprecated": "This option no longer has any effect. Cypress supports typescript out of the box. Add any options directly to <projectRoot>/tsconfig.json or <projectRoot>/cypress/tsconfig.json",
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "The path of the Cypress tsconfig configuration json file.",
|
|
38
|
+
"x-completion-type": "file",
|
|
39
|
+
"x-completion-glob": "tsconfig.*.json"
|
|
40
|
+
},
|
|
41
|
+
"devServerTarget": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "Dev server target to run tests against."
|
|
44
|
+
},
|
|
45
|
+
"headed": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"description": "Displays the browser instead of running headlessly. Set this to `true` if your run depends on a Chrome extension being loaded.",
|
|
48
|
+
"default": false
|
|
49
|
+
},
|
|
50
|
+
"headless": {
|
|
51
|
+
"type": "boolean",
|
|
52
|
+
"description": "Hide the browser instead of running headed.",
|
|
53
|
+
"default": false,
|
|
54
|
+
"x-deprecated": "Cypress runs headless by default. Use the --watch flag to control head/headless behavior instead."
|
|
55
|
+
},
|
|
56
|
+
"exit": {
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"description": "Whether or not the Cypress Test Runner will stay open after running tests in a spec file.",
|
|
59
|
+
"default": true
|
|
60
|
+
},
|
|
61
|
+
"key": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"description": "The key cypress should use to run tests in parallel/record the run (CI only)."
|
|
64
|
+
},
|
|
65
|
+
"record": {
|
|
66
|
+
"type": "boolean",
|
|
67
|
+
"description": "Whether or not Cypress should record the results of the tests.",
|
|
68
|
+
"default": false
|
|
69
|
+
},
|
|
70
|
+
"parallel": {
|
|
71
|
+
"aliases": ["p"],
|
|
72
|
+
"type": "boolean",
|
|
73
|
+
"description": "Whether or not Cypress should run its tests in parallel (CI only).",
|
|
74
|
+
"default": false
|
|
75
|
+
},
|
|
76
|
+
"baseUrl": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "The address (with the port) which your application is running on.",
|
|
79
|
+
"x-priority": "important"
|
|
80
|
+
},
|
|
81
|
+
"browser": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"description": "The browser to run tests in."
|
|
84
|
+
},
|
|
85
|
+
"env": {
|
|
86
|
+
"type": "object",
|
|
87
|
+
"description": "A key-value Pair of environment variables to pass to Cypress runner."
|
|
88
|
+
},
|
|
89
|
+
"spec": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"description": "A comma delimited glob string that is provided to the Cypress runner to specify which spec files to run. i.e. `**examples/**,**actions.spec**`."
|
|
92
|
+
},
|
|
93
|
+
"copyFiles": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"description": "A regex string that is used to choose what additional integration files to copy to the dist folder.",
|
|
96
|
+
"x-deprecated": "No longer used since cypress supports typescript out of the box. If specified, it will be ignored.",
|
|
97
|
+
"x-priority": "internal"
|
|
98
|
+
},
|
|
99
|
+
"ciBuildId": {
|
|
100
|
+
"oneOf": [
|
|
101
|
+
{
|
|
102
|
+
"type": "string"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"type": "number"
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
"description": "A unique identifier for a run to enable grouping or parallelization."
|
|
109
|
+
},
|
|
110
|
+
"group": {
|
|
111
|
+
"type": "string",
|
|
112
|
+
"description": "A named group for recorded runs in the Cypress dashboard."
|
|
113
|
+
},
|
|
114
|
+
"ignoreTestFiles": {
|
|
115
|
+
"aliases": ["excludeSpecPattern"],
|
|
116
|
+
"oneOf": [
|
|
117
|
+
{
|
|
118
|
+
"type": "string"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"type": "array",
|
|
122
|
+
"items": {
|
|
123
|
+
"type": "string"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"description": "A String or Array of glob patterns used to ignore test files that would otherwise be shown in your list of tests. Cypress uses minimatch with the options: `{dot: true, matchBase: true}`. We suggest using https://globster.xyz to test what files would match."
|
|
128
|
+
},
|
|
129
|
+
"reporter": {
|
|
130
|
+
"type": "string",
|
|
131
|
+
"description": "The reporter used during cypress run."
|
|
132
|
+
},
|
|
133
|
+
"reporterOptions": {
|
|
134
|
+
"oneOf": [
|
|
135
|
+
{
|
|
136
|
+
"type": "string"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"type": "object"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"description": "The reporter options used. Supported options depend on the reporter. https://docs.cypress.io/guides/tooling/reporters#Reporter-Options"
|
|
143
|
+
},
|
|
144
|
+
"skipServe": {
|
|
145
|
+
"type": "boolean",
|
|
146
|
+
"description": "Skip dev-server build.",
|
|
147
|
+
"default": false
|
|
148
|
+
},
|
|
149
|
+
"testingType": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"description": "Specify the type of tests to execute.",
|
|
152
|
+
"enum": ["component", "e2e"],
|
|
153
|
+
"default": "e2e"
|
|
154
|
+
},
|
|
155
|
+
"tag": {
|
|
156
|
+
"type": "string",
|
|
157
|
+
"description": "A comma delimited list to identify a run with.",
|
|
158
|
+
"aliases": ["t"]
|
|
159
|
+
},
|
|
160
|
+
"port": {
|
|
161
|
+
"oneOf": [
|
|
162
|
+
{
|
|
163
|
+
"type": "string",
|
|
164
|
+
"enum": ["cypress-auto"]
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"type": "number"
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
"description": "Pass a specified port value to the devServerTarget, if the value is 'cypress-auto' a free port will automatically be picked for the devServerTarget."
|
|
171
|
+
},
|
|
172
|
+
"quiet": {
|
|
173
|
+
"aliases": ["q"],
|
|
174
|
+
"type": "boolean",
|
|
175
|
+
"description": "If passed, Cypress output will not be printed to stdout. Only output from the configured Mocha reporter will print.",
|
|
176
|
+
"default": false
|
|
177
|
+
},
|
|
178
|
+
"runnerUi": {
|
|
179
|
+
"type": "boolean",
|
|
180
|
+
"description": "Displays the Cypress Runner UI. Useful for when Test Replay is enabled and you would still like the Cypress Runner UI to be displayed for screenshots and video."
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
"additionalProperties": true,
|
|
184
|
+
"required": ["cypressConfig"],
|
|
185
|
+
"examplesFile": "../../../docs/cypress-examples.md"
|
|
186
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
js?: boolean;
|
|
10
|
+
jsx?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function addBaseCypressSetup(tree: Tree, options: CypressBaseSetupSchema): void;
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'cypress.config.js'))) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const opts = normalizeOptions(tree, projectConfig, options);
|
|
14
|
+
const templateVars = {
|
|
15
|
+
...opts,
|
|
16
|
+
jsx: !!opts.jsx,
|
|
17
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(projectConfig.root),
|
|
18
|
+
offsetFromProjectRoot: opts.hasTsConfig ? opts.offsetFromProjectRoot : '',
|
|
19
|
+
tsConfigPath: opts.hasTsConfig
|
|
20
|
+
? `${opts.offsetFromProjectRoot}tsconfig.json`
|
|
21
|
+
: (0, js_1.getRelativePathToRootTsConfig)(tree, projectConfig.root),
|
|
22
|
+
ext: '',
|
|
23
|
+
};
|
|
24
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files/common'), projectConfig.root, templateVars);
|
|
25
|
+
if (options.js) {
|
|
26
|
+
if (isEsmProject(tree, projectConfig.root)) {
|
|
27
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files/config-js-esm'), projectConfig.root, templateVars);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files/config-js-cjs'), projectConfig.root, templateVars);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files/config-ts'), projectConfig.root, templateVars);
|
|
35
|
+
}
|
|
36
|
+
if (opts.hasTsConfig) {
|
|
37
|
+
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'), (json) => {
|
|
38
|
+
// tsconfig doesn't have references so it shouldn't add them
|
|
39
|
+
// like in the case of nextjs apps.
|
|
40
|
+
if (!json.references) {
|
|
41
|
+
return json;
|
|
42
|
+
}
|
|
43
|
+
const tsconfigPath = `./${options.directory}/tsconfig.json`;
|
|
44
|
+
if (!json.references.some((ref) => ref.path === tsconfigPath)) {
|
|
45
|
+
json.references.push({
|
|
46
|
+
path: tsconfigPath,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return json;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
tree.rename((0, devkit_1.joinPathFragments)(projectConfig.root, options.directory, 'tsconfig.json'), (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.addBaseCypressSetup = addBaseCypressSetup;
|
|
57
|
+
function normalizeOptions(tree, projectConfig, options) {
|
|
58
|
+
options.directory ??= 'cypress';
|
|
59
|
+
const offsetFromProjectRoot = options.directory
|
|
60
|
+
.split('/')
|
|
61
|
+
.map((_) => '..')
|
|
62
|
+
.join('/');
|
|
63
|
+
const hasTsConfig = tree.exists((0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json'));
|
|
64
|
+
return {
|
|
65
|
+
...options,
|
|
66
|
+
projectConfig,
|
|
67
|
+
offsetFromProjectRoot: `${offsetFromProjectRoot}/`,
|
|
68
|
+
hasTsConfig,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function isEsmProject(tree, projectRoot) {
|
|
72
|
+
let packageJson;
|
|
73
|
+
if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))) {
|
|
74
|
+
packageJson = (0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
packageJson = (0, devkit_1.readJson)(tree, 'package.json');
|
|
78
|
+
}
|
|
79
|
+
return packageJson.type === 'module';
|
|
80
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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) => { ... })
|
|
@@ -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
|
+
<% if (jsx) { %> "<%= offsetFromProjectRoot %>**/*.cy.tsx",<% } %>
|
|
16
|
+
"<%= offsetFromProjectRoot %>**/*.cy.js",
|
|
17
|
+
<% if (jsx) { %>"<%= offsetFromProjectRoot %>**/*.cy.jsx",<% } %>
|
|
18
|
+
"<%= offsetFromProjectRoot %>**/*.d.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
package/src/generators/base-setup/files/config-js-cjs/__directory__/support/commands.js__ext__
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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__
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
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) => { ... })
|
|
@@ -0,0 +1,35 @@
|
|
|
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) => { ... })
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ProjectConfiguration, Tree, GeneratorCallback } from '@nx/devkit';
|
|
2
|
+
import { CypressComponentConfigurationSchema } from './schema';
|
|
3
|
+
export declare function componentConfigurationGenerator(tree: Tree, options: CypressComponentConfigurationSchema): Promise<GeneratorCallback>;
|
|
4
|
+
export declare function componentConfigurationGeneratorInternal(tree: Tree, options: CypressComponentConfigurationSchema): Promise<GeneratorCallback>;
|
|
5
|
+
export declare function updateTsConfigForComponentTesting(tree: Tree, projectConfig: ProjectConfiguration): void;
|
|
6
|
+
export default componentConfigurationGenerator;
|