@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,7 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
export declare function updateToCypress13(tree: Tree): Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* leave a comment on all usages of overriding built-ins that are now banned
|
|
5
|
+
**/
|
|
6
|
+
export declare function shouldNotOverrideReadFile(tree: Tree, filePath: string): void;
|
|
7
|
+
export default updateToCypress13;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldNotOverrideReadFile = exports.updateToCypress13 = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const cypress_version_1 = require("../../utils/cypress-version");
|
|
6
|
+
const typescript_1 = require("typescript");
|
|
7
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
8
|
+
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
9
|
+
const JS_TS_FILE_MATCHER = /\.[jt]sx?$/;
|
|
10
|
+
async function updateToCypress13(tree) {
|
|
11
|
+
if ((0, cypress_version_1.installedCypressVersion)() < 12) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
15
|
+
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/cypress:cypress', (options, projectName) => {
|
|
16
|
+
if (!options.cypressConfig || !tree.exists(options.cypressConfig)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const projectConfig = projects.get(projectName);
|
|
20
|
+
removeNodeVersionOption(tree, options.cypressConfig);
|
|
21
|
+
removeVideoUploadOnPassesOption(tree, options.cypressConfig);
|
|
22
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
|
|
23
|
+
if (!JS_TS_FILE_MATCHER.test(filePath)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
shouldNotOverrideReadFile(tree, filePath);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (json) => {
|
|
30
|
+
json.devDependencies ??= {};
|
|
31
|
+
json.devDependencies.cypress = '^13.0.0';
|
|
32
|
+
return json;
|
|
33
|
+
});
|
|
34
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
35
|
+
}
|
|
36
|
+
exports.updateToCypress13 = updateToCypress13;
|
|
37
|
+
function removeVideoUploadOnPassesOption(tree, configPath) {
|
|
38
|
+
const config = tree.read(configPath, 'utf-8');
|
|
39
|
+
const isUsingDeprecatedOption = tsquery_1.tsquery.query(config, getPropertyQuery('videoUploadOnPasses'))?.length > 0;
|
|
40
|
+
if (!isUsingDeprecatedOption) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const importStatement = configPath.endsWith('.ts')
|
|
44
|
+
? "import fs from 'fs';"
|
|
45
|
+
: "const fs = require('fs');";
|
|
46
|
+
const replacementFunction = `/**
|
|
47
|
+
* Delete videos for specs that do not contain failing or retried tests.
|
|
48
|
+
* This function is to be used in the 'setupNodeEvents' configuration option as a replacement to
|
|
49
|
+
* 'videoUploadOnPasses' which has been removed.
|
|
50
|
+
*
|
|
51
|
+
* https://docs.cypress.io/guides/guides/screenshots-and-videos#Delete-videos-for-specs-without-failing-or-retried-tests
|
|
52
|
+
**/
|
|
53
|
+
function removePassedSpecs(on) {
|
|
54
|
+
on('after:spec', (spec, results) => {
|
|
55
|
+
if(results && results.vide) {
|
|
56
|
+
const hasFailures = results.tests.some(t => t.attempts.some(a => a.state === 'failed'));
|
|
57
|
+
|
|
58
|
+
if(!hasFailures) {
|
|
59
|
+
fs.unlinkSync(results.video);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
}`;
|
|
64
|
+
const withReplacementFn = `${importStatement}\n${config}\n${replacementFunction}`;
|
|
65
|
+
// setupNodeEvents can be a property or method.
|
|
66
|
+
const setupNodeEventsQuery = 'ExportAssignment ObjectLiteralExpression > :matches(PropertyAssignment:has(Identifier[name="setupNodeEvents"]), MethodDeclaration:has(Identifier[name="setupNodeEvents"]))';
|
|
67
|
+
const hasSetupNodeEvents = tsquery_1.tsquery.query(withReplacementFn, setupNodeEventsQuery)?.length > 0;
|
|
68
|
+
let updatedWithSetupNodeEvents = withReplacementFn;
|
|
69
|
+
if (hasSetupNodeEvents) {
|
|
70
|
+
// if have setupNodeEvents, update existing fn to use removePassedSpecs helper and remove videoUploadOnPasses
|
|
71
|
+
const noVideoUploadOption = tsquery_1.tsquery.replace(withReplacementFn, getPropertyQuery('videoUploadOnPasses'), (node) => {
|
|
72
|
+
if ((0, typescript_1.isObjectLiteralExpression)(node.initializer)) {
|
|
73
|
+
// is a nested config object
|
|
74
|
+
const key = node.name.getText().trim();
|
|
75
|
+
const listOfProperties = node.initializer.properties
|
|
76
|
+
.map((j) => j.getText())
|
|
77
|
+
.filter((j) => !j.includes('videoUploadOnPasses'))
|
|
78
|
+
.join(',\n');
|
|
79
|
+
return `${key}: {
|
|
80
|
+
${listOfProperties}
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
if (isPropertyTopLevel(node)) {
|
|
86
|
+
return `// ${node.getText()} `;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
updatedWithSetupNodeEvents = tsquery_1.tsquery.replace(noVideoUploadOption, `${setupNodeEventsQuery} Block`, (node) => {
|
|
91
|
+
const blockWithoutBraces = node
|
|
92
|
+
.getFullText()
|
|
93
|
+
.trim()
|
|
94
|
+
.slice(1, -1)
|
|
95
|
+
.trim();
|
|
96
|
+
return `{
|
|
97
|
+
${blockWithoutBraces}
|
|
98
|
+
removePassedSpecs(on);
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
}, { visitAllChildren: false });
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
// if don't have setupNodeEvents, replace videoUploadOnPasses with setupNodeEvents method
|
|
105
|
+
updatedWithSetupNodeEvents = tsquery_1.tsquery.replace(withReplacementFn, getPropertyQuery('videoUploadOnPasses'), () => {
|
|
106
|
+
return `setupNodeEvents(on, config) {
|
|
107
|
+
removePassedSpecs(on);
|
|
108
|
+
}`;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
tree.write(configPath, updatedWithSetupNodeEvents);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* remove the nodeVersion option from the config file
|
|
115
|
+
**/
|
|
116
|
+
function removeNodeVersionOption(tree, configPath) {
|
|
117
|
+
const config = tree.read(configPath, 'utf-8');
|
|
118
|
+
const updated = tsquery_1.tsquery.replace(config, getPropertyQuery('nodeVersion'), (node) => {
|
|
119
|
+
if ((0, typescript_1.isObjectLiteralExpression)(node.initializer)) {
|
|
120
|
+
// is a nested config object
|
|
121
|
+
const key = node.name.getText().trim();
|
|
122
|
+
const listOfProperties = node.initializer.properties
|
|
123
|
+
.map((j) => j.getFullText())
|
|
124
|
+
.filter((j) => !j.includes('nodeVersion'))
|
|
125
|
+
.join(', ');
|
|
126
|
+
return `${key}: {
|
|
127
|
+
${listOfProperties}
|
|
128
|
+
}`;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
if (isPropertyTopLevel(node)) {
|
|
132
|
+
return `// ${node.getText()}`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
if (updated !== config) {
|
|
137
|
+
tree.write(configPath, updated);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* leave a comment on all usages of overriding built-ins that are now banned
|
|
142
|
+
**/
|
|
143
|
+
function shouldNotOverrideReadFile(tree, filePath) {
|
|
144
|
+
const content = tree.read(filePath, 'utf-8');
|
|
145
|
+
const markedOverrideUsage = tsquery_1.tsquery.replace(content, 'PropertyAccessExpression:has(Identifier[name="overwrite"]):has(Identifier[name="Cypress"])', (node) => {
|
|
146
|
+
if (isAlreadyCommented(node)) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const expression = node.expression.getText().trim();
|
|
150
|
+
// prevent grabbing other Cypress.<something>.defaults
|
|
151
|
+
if (expression === 'Cypress.Commands') {
|
|
152
|
+
// get value.
|
|
153
|
+
const overwriteExpression = node.parent;
|
|
154
|
+
const command = overwriteExpression.arguments?.[0]?.text; // need string without quotes
|
|
155
|
+
if (command === 'readFile') {
|
|
156
|
+
// overwrite
|
|
157
|
+
return `/**
|
|
158
|
+
* TODO(@nx/cypress): This command can no longer be overridden
|
|
159
|
+
* Consider using a different name like 'custom_${command}'
|
|
160
|
+
* More info: https://docs.cypress.io/guides/references/migration-guide#readFile-can-no-longer-be-overwritten-with-CypressCommandsoverwrite
|
|
161
|
+
**/
|
|
162
|
+
${node.getText()}`;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
tree.write(filePath, markedOverrideUsage);
|
|
167
|
+
}
|
|
168
|
+
exports.shouldNotOverrideReadFile = shouldNotOverrideReadFile;
|
|
169
|
+
function isAlreadyCommented(node) {
|
|
170
|
+
return node.getFullText().includes('TODO(@nx/cypress)');
|
|
171
|
+
}
|
|
172
|
+
function isPropertyTopLevel(node) {
|
|
173
|
+
return (node.parent &&
|
|
174
|
+
(0, typescript_1.isObjectLiteralExpression)(node.parent) &&
|
|
175
|
+
node.parent.parent &&
|
|
176
|
+
(0, typescript_1.isCallExpression)(node.parent.parent));
|
|
177
|
+
}
|
|
178
|
+
const getPropertyQuery = (propertyName) => `ExportAssignment ObjectLiteralExpression > PropertyAssignment:has(Identifier[name="${propertyName}"])`;
|
|
179
|
+
exports.default = updateToCypress13;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const cypress_version_1 = require("../../utils/cypress-version");
|
|
5
|
+
async function default_1(tree) {
|
|
6
|
+
if ((0, cypress_version_1.installedCypressVersion)() < 13) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, { cypress: '^13.6.6' });
|
|
10
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
11
|
+
}
|
|
12
|
+
exports.default = default_1;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CreateDependencies, CreateNodes } from '@nx/devkit';
|
|
2
|
+
export interface CypressPluginOptions {
|
|
3
|
+
ciTargetName?: string;
|
|
4
|
+
targetName?: string;
|
|
5
|
+
componentTestingTargetName?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const createDependencies: CreateDependencies;
|
|
8
|
+
export declare const createNodes: CreateNodes<CypressPluginOptions>;
|
|
@@ -0,0 +1,195 @@
|
|
|
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 = targetsCache[hash]
|
|
43
|
+
? targetsCache[hash]
|
|
44
|
+
: await buildCypressTargets(configFilePath, projectRoot, options, context);
|
|
45
|
+
calculatedTargets[hash] = targets;
|
|
46
|
+
return {
|
|
47
|
+
projects: {
|
|
48
|
+
[projectRoot]: {
|
|
49
|
+
projectType: 'application',
|
|
50
|
+
targets,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
function getOutputs(projectRoot, cypressConfig, testingType) {
|
|
57
|
+
function getOutput(path) {
|
|
58
|
+
if (path.startsWith('..')) {
|
|
59
|
+
return (0, path_1.join)('{workspaceRoot}', (0, path_1.join)(projectRoot, path));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return (0, path_1.join)('{projectRoot}', path);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const { screenshotsFolder, videosFolder, e2e, component } = cypressConfig;
|
|
66
|
+
const outputs = [];
|
|
67
|
+
if (videosFolder) {
|
|
68
|
+
outputs.push(getOutput(videosFolder));
|
|
69
|
+
}
|
|
70
|
+
if (screenshotsFolder) {
|
|
71
|
+
outputs.push(getOutput(screenshotsFolder));
|
|
72
|
+
}
|
|
73
|
+
switch (testingType) {
|
|
74
|
+
case 'e2e': {
|
|
75
|
+
if (e2e.videosFolder) {
|
|
76
|
+
outputs.push(getOutput(e2e.videosFolder));
|
|
77
|
+
}
|
|
78
|
+
if (e2e.screenshotsFolder) {
|
|
79
|
+
outputs.push(getOutput(e2e.screenshotsFolder));
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
case 'component': {
|
|
84
|
+
if (component.videosFolder) {
|
|
85
|
+
outputs.push(getOutput(component.videosFolder));
|
|
86
|
+
}
|
|
87
|
+
if (component.screenshotsFolder) {
|
|
88
|
+
outputs.push(getOutput(component.screenshotsFolder));
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return outputs;
|
|
94
|
+
}
|
|
95
|
+
async function buildCypressTargets(configFilePath, projectRoot, options, context) {
|
|
96
|
+
const cypressConfig = await (0, config_utils_1.loadConfigFile)((0, path_1.join)(context.workspaceRoot, configFilePath));
|
|
97
|
+
const pluginPresetOptions = {
|
|
98
|
+
...cypressConfig.e2e?.[constants_1.NX_PLUGIN_OPTIONS],
|
|
99
|
+
...cypressConfig.env,
|
|
100
|
+
...cypressConfig.e2e?.env,
|
|
101
|
+
};
|
|
102
|
+
const webServerCommands = pluginPresetOptions?.webServerCommands;
|
|
103
|
+
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
104
|
+
const targets = {};
|
|
105
|
+
if ('e2e' in cypressConfig) {
|
|
106
|
+
targets[options.targetName] = {
|
|
107
|
+
command: `cypress run`,
|
|
108
|
+
options: { cwd: projectRoot },
|
|
109
|
+
cache: true,
|
|
110
|
+
inputs: getInputs(namedInputs),
|
|
111
|
+
outputs: getOutputs(projectRoot, cypressConfig, 'e2e'),
|
|
112
|
+
};
|
|
113
|
+
if (webServerCommands?.default) {
|
|
114
|
+
delete webServerCommands.default;
|
|
115
|
+
}
|
|
116
|
+
if (Object.keys(webServerCommands ?? {}).length > 0) {
|
|
117
|
+
targets[options.targetName].configurations ??= {};
|
|
118
|
+
for (const [configuration, webServerCommand] of Object.entries(webServerCommands ?? {})) {
|
|
119
|
+
targets[options.targetName].configurations[configuration] = {
|
|
120
|
+
command: `cypress run --env webServerCommand="${webServerCommand}"`,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const ciWebServerCommand = pluginPresetOptions?.ciWebServerCommand;
|
|
125
|
+
if (ciWebServerCommand) {
|
|
126
|
+
const specPatterns = Array.isArray(cypressConfig.e2e.specPattern)
|
|
127
|
+
? cypressConfig.e2e.specPattern.map((p) => (0, path_1.join)(projectRoot, p))
|
|
128
|
+
: [(0, path_1.join)(projectRoot, cypressConfig.e2e.specPattern)];
|
|
129
|
+
const excludeSpecPatterns = !cypressConfig.e2e
|
|
130
|
+
.excludeSpecPattern
|
|
131
|
+
? cypressConfig.e2e.excludeSpecPattern
|
|
132
|
+
: Array.isArray(cypressConfig.e2e.excludeSpecPattern)
|
|
133
|
+
? cypressConfig.e2e.excludeSpecPattern.map((p) => (0, path_1.join)(projectRoot, p))
|
|
134
|
+
: [(0, path_1.join)(projectRoot, cypressConfig.e2e.excludeSpecPattern)];
|
|
135
|
+
const specFiles = (0, workspace_context_1.globWithWorkspaceContext)(context.workspaceRoot, specPatterns, excludeSpecPatterns);
|
|
136
|
+
const dependsOn = [];
|
|
137
|
+
const outputs = getOutputs(projectRoot, cypressConfig, 'e2e');
|
|
138
|
+
const inputs = getInputs(namedInputs);
|
|
139
|
+
for (const file of specFiles) {
|
|
140
|
+
const relativeSpecFilePath = (0, path_1.relative)(projectRoot, file);
|
|
141
|
+
const targetName = options.ciTargetName + '--' + relativeSpecFilePath;
|
|
142
|
+
targets[targetName] = {
|
|
143
|
+
outputs,
|
|
144
|
+
inputs,
|
|
145
|
+
cache: true,
|
|
146
|
+
command: `cypress run --env webServerCommand="${ciWebServerCommand}" --spec ${relativeSpecFilePath}`,
|
|
147
|
+
options: {
|
|
148
|
+
cwd: projectRoot,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
dependsOn.push({
|
|
152
|
+
target: targetName,
|
|
153
|
+
projects: 'self',
|
|
154
|
+
params: 'forward',
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
targets[options.ciTargetName] ??= {};
|
|
158
|
+
targets[options.ciTargetName] = {
|
|
159
|
+
executor: 'nx:noop',
|
|
160
|
+
cache: true,
|
|
161
|
+
inputs,
|
|
162
|
+
outputs,
|
|
163
|
+
dependsOn,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if ('component' in cypressConfig) {
|
|
168
|
+
// This will not override the e2e target if it is the same
|
|
169
|
+
targets[options.componentTestingTargetName] ??= {
|
|
170
|
+
command: `cypress run --component`,
|
|
171
|
+
options: { cwd: projectRoot },
|
|
172
|
+
cache: true,
|
|
173
|
+
inputs: getInputs(namedInputs),
|
|
174
|
+
outputs: getOutputs(projectRoot, cypressConfig, 'component'),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return targets;
|
|
178
|
+
}
|
|
179
|
+
function normalizeOptions(options) {
|
|
180
|
+
options ??= {};
|
|
181
|
+
options.targetName ??= 'e2e';
|
|
182
|
+
options.componentTestingTargetName ??= 'component-test';
|
|
183
|
+
options.ciTargetName ??= 'e2e-ci';
|
|
184
|
+
return options;
|
|
185
|
+
}
|
|
186
|
+
function getInputs(namedInputs) {
|
|
187
|
+
return [
|
|
188
|
+
...('production' in namedInputs
|
|
189
|
+
? ['default', '^production']
|
|
190
|
+
: ['default', '^default']),
|
|
191
|
+
{
|
|
192
|
+
externalDependencies: ['cypress'],
|
|
193
|
+
},
|
|
194
|
+
];
|
|
195
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://github.com/mammadataei/cypress-vite
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2022 Mohammad Ataei
|
|
7
|
+
*
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
9
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
10
|
+
* the Software without restriction, including without limitation the rights to
|
|
11
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
12
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
13
|
+
* subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
* copies or substantial portions of the Software.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
20
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
21
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
22
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
23
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
**/
|
|
25
|
+
type CypressPreprocessor = (file: Record<string, any>) => string | Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Use Vite as a file preprocess for Cypress test files.
|
|
28
|
+
* This preprocessor shouldn't be used directly.
|
|
29
|
+
* Instead, use the nxE2EPreset(__filename, { bundler: 'vite' }) function instead.
|
|
30
|
+
*/
|
|
31
|
+
declare function vitePreprocessor(userConfigPath?: string): CypressPreprocessor;
|
|
32
|
+
export default vitePreprocessor;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/mammadataei/cypress-vite
|
|
4
|
+
*
|
|
5
|
+
* MIT License
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2022 Mohammad Ataei
|
|
8
|
+
*
|
|
9
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
10
|
+
* this software and associated documentation files (the "Software"), to deal in
|
|
11
|
+
* the Software without restriction, including without limitation the rights to
|
|
12
|
+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
13
|
+
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
14
|
+
* subject to the following conditions:
|
|
15
|
+
*
|
|
16
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
* copies or substantial portions of the Software.
|
|
18
|
+
*
|
|
19
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
21
|
+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
22
|
+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
23
|
+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
24
|
+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25
|
+
**/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
const path_1 = require("path");
|
|
28
|
+
const cache = new Map();
|
|
29
|
+
/**
|
|
30
|
+
* Use Vite as a file preprocess for Cypress test files.
|
|
31
|
+
* This preprocessor shouldn't be used directly.
|
|
32
|
+
* Instead, use the nxE2EPreset(__filename, { bundler: 'vite' }) function instead.
|
|
33
|
+
*/
|
|
34
|
+
function vitePreprocessor(userConfigPath) {
|
|
35
|
+
return async (file) => {
|
|
36
|
+
const { outputPath, filePath, shouldWatch } = file;
|
|
37
|
+
if (cache.has(filePath)) {
|
|
38
|
+
return cache.get(filePath);
|
|
39
|
+
}
|
|
40
|
+
const fileName = (0, path_1.basename)(outputPath);
|
|
41
|
+
const filenameWithoutExtension = (0, path_1.basename)(outputPath, (0, path_1.extname)(outputPath));
|
|
42
|
+
const defaultConfig = {
|
|
43
|
+
logLevel: 'silent',
|
|
44
|
+
define: {
|
|
45
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
46
|
+
},
|
|
47
|
+
build: {
|
|
48
|
+
emptyOutDir: false,
|
|
49
|
+
minify: false,
|
|
50
|
+
outDir: (0, path_1.dirname)(outputPath),
|
|
51
|
+
sourcemap: true,
|
|
52
|
+
write: true,
|
|
53
|
+
watch: getWatcherConfig(shouldWatch),
|
|
54
|
+
lib: {
|
|
55
|
+
entry: filePath,
|
|
56
|
+
fileName: () => fileName,
|
|
57
|
+
formats: ['umd'],
|
|
58
|
+
name: filenameWithoutExtension,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
cache.set(filePath, outputPath);
|
|
63
|
+
const { build } = await Function('return import("vite")')();
|
|
64
|
+
const watcher = (await build({
|
|
65
|
+
configFile: userConfigPath,
|
|
66
|
+
...defaultConfig,
|
|
67
|
+
}));
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
if (shouldWatch && isWatcher(watcher)) {
|
|
70
|
+
watcher.on('event', (event) => {
|
|
71
|
+
if (event.code === 'END') {
|
|
72
|
+
resolve(outputPath);
|
|
73
|
+
file.emit('rerun');
|
|
74
|
+
}
|
|
75
|
+
if (event.code === 'ERROR') {
|
|
76
|
+
console.error(event);
|
|
77
|
+
reject(new Error(event.error.message));
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
file.on('close', () => {
|
|
81
|
+
cache.delete(filePath);
|
|
82
|
+
watcher.close();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
resolve(outputPath);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function isWatcher(maybeWatcher) {
|
|
92
|
+
return maybeWatcher.on !== undefined;
|
|
93
|
+
}
|
|
94
|
+
function getWatcherConfig(shouldWatch) {
|
|
95
|
+
return shouldWatch ? {} : null;
|
|
96
|
+
}
|
|
97
|
+
exports.default = vitePreprocessor;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
import { Linter } from '@nx/eslint';
|
|
3
|
+
export interface CyLinterOptions {
|
|
4
|
+
project: string;
|
|
5
|
+
linter: Linter;
|
|
6
|
+
setParserOptionsProject?: boolean;
|
|
7
|
+
skipPackageJson?: boolean;
|
|
8
|
+
rootProject?: boolean;
|
|
9
|
+
js?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Directory from the project root, where the cypress files will be located.
|
|
12
|
+
* typically src/ or cypress/
|
|
13
|
+
**/
|
|
14
|
+
cypressDir: string;
|
|
15
|
+
/**
|
|
16
|
+
* overwrite existing eslint rules for the cypress defaults
|
|
17
|
+
* This is useful when adding linting to a brand new project vs an existing one
|
|
18
|
+
**/
|
|
19
|
+
overwriteExisting?: boolean;
|
|
20
|
+
addPlugin?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function addLinterToCyProject(tree: Tree, options: CyLinterOptions): Promise<() => void>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addLinterToCyProject = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const eslint_1 = require("@nx/eslint");
|
|
6
|
+
const cypress_version_1 = require("./cypress-version");
|
|
7
|
+
const versions_1 = require("./versions");
|
|
8
|
+
const eslint_file_1 = require("@nx/eslint/src/generators/utils/eslint-file");
|
|
9
|
+
const global_eslint_config_1 = require("@nx/eslint/src/generators/init/global-eslint-config");
|
|
10
|
+
async function addLinterToCyProject(tree, options) {
|
|
11
|
+
if (options.linter === eslint_1.Linter.None) {
|
|
12
|
+
return () => { };
|
|
13
|
+
}
|
|
14
|
+
const tasks = [];
|
|
15
|
+
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
16
|
+
const eslintFile = (0, eslint_file_1.findEslintFile)(tree, projectConfig.root);
|
|
17
|
+
if (!eslintFile) {
|
|
18
|
+
tasks.push(await (0, eslint_1.lintProjectGenerator)(tree, {
|
|
19
|
+
project: options.project,
|
|
20
|
+
linter: options.linter,
|
|
21
|
+
skipFormat: true,
|
|
22
|
+
tsConfigPaths: [(0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json')],
|
|
23
|
+
setParserOptionsProject: options.setParserOptionsProject,
|
|
24
|
+
skipPackageJson: options.skipPackageJson,
|
|
25
|
+
rootProject: options.rootProject,
|
|
26
|
+
addPlugin: options.addPlugin,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
if (!options.linter || options.linter !== eslint_1.Linter.EsLint) {
|
|
30
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
31
|
+
}
|
|
32
|
+
options.overwriteExisting = options.overwriteExisting || !eslintFile;
|
|
33
|
+
tasks.push(!options.skipPackageJson
|
|
34
|
+
? (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { 'eslint-plugin-cypress': versions_1.eslintPluginCypressVersion })
|
|
35
|
+
: () => { });
|
|
36
|
+
if ((0, eslint_file_1.isEslintConfigSupported)(tree)) {
|
|
37
|
+
const overrides = [];
|
|
38
|
+
if (options.rootProject) {
|
|
39
|
+
(0, eslint_file_1.addPluginsToLintConfig)(tree, projectConfig.root, '@nx');
|
|
40
|
+
overrides.push(global_eslint_config_1.typeScriptOverride);
|
|
41
|
+
overrides.push(global_eslint_config_1.javaScriptOverride);
|
|
42
|
+
}
|
|
43
|
+
(0, eslint_file_1.addExtendsToLintConfig)(tree, projectConfig.root, 'plugin:cypress/recommended');
|
|
44
|
+
const cyVersion = (0, cypress_version_1.installedCypressVersion)();
|
|
45
|
+
/**
|
|
46
|
+
* We need this override because we enabled allowJS in the tsconfig to allow for JS based Cypress tests.
|
|
47
|
+
* That however leads to issues with the CommonJS Cypress plugin file.
|
|
48
|
+
*/
|
|
49
|
+
const cy6Override = {
|
|
50
|
+
files: [`${options.cypressDir}/plugins/index.js`],
|
|
51
|
+
rules: {
|
|
52
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
53
|
+
'no-undef': 'off',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
const addCy6Override = cyVersion && cyVersion < 7;
|
|
57
|
+
if (options.overwriteExisting) {
|
|
58
|
+
overrides.unshift({
|
|
59
|
+
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
|
|
60
|
+
parserOptions: !options.setParserOptionsProject
|
|
61
|
+
? undefined
|
|
62
|
+
: {
|
|
63
|
+
project: `${projectConfig.root}/tsconfig.*?.json`,
|
|
64
|
+
},
|
|
65
|
+
rules: {},
|
|
66
|
+
});
|
|
67
|
+
if (addCy6Override) {
|
|
68
|
+
overrides.push(cy6Override);
|
|
69
|
+
}
|
|
70
|
+
(0, eslint_file_1.replaceOverridesInLintConfig)(tree, projectConfig.root, overrides);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
overrides.unshift({
|
|
74
|
+
files: [
|
|
75
|
+
'*.cy.{ts,js,tsx,jsx}',
|
|
76
|
+
`${options.cypressDir}/**/*.{ts,js,tsx,jsx}`,
|
|
77
|
+
],
|
|
78
|
+
parserOptions: !options.setParserOptionsProject
|
|
79
|
+
? undefined
|
|
80
|
+
: {
|
|
81
|
+
project: `${projectConfig.root}/tsconfig.*?.json`,
|
|
82
|
+
},
|
|
83
|
+
rules: {},
|
|
84
|
+
});
|
|
85
|
+
if (addCy6Override) {
|
|
86
|
+
overrides.push(cy6Override);
|
|
87
|
+
}
|
|
88
|
+
overrides.forEach((override) => (0, eslint_file_1.addOverrideToLintConfig)(tree, projectConfig.root, override));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
92
|
+
}
|
|
93
|
+
exports.addLinterToCyProject = addLinterToCyProject;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
import type { NxComponentTestingOptions, NxCypressE2EPresetOptions } from '../../plugins/cypress-preset';
|
|
3
|
+
export declare const CYPRESS_CONFIG_FILE_NAME_PATTERN = "cypress.config.{js,ts,mjs,cjs}";
|
|
4
|
+
export declare function addDefaultE2EConfig(cyConfigContents: string, options: NxCypressE2EPresetOptions, baseUrl: string): 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?: NxComponentTestingOptions): Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Adds the mount command for Cypress
|
|
13
|
+
* Make sure after calling this the correct import statement is added
|
|
14
|
+
* to bring in the correct mount from cypress.
|
|
15
|
+
**/
|
|
16
|
+
export declare function addMountDefinition(cmpCommandFileContents: string): Promise<string>;
|
|
17
|
+
export declare function getProjectCypressConfigPath(tree: Tree, projectRoot: string): string;
|