@nx/cypress 17.2.0-beta.1 → 17.2.0-beta.2
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
CHANGED
|
@@ -52,11 +52,6 @@
|
|
|
52
52
|
"version": "17.2.0-beta.0",
|
|
53
53
|
"description": "Add devServerTargets into cypress.config.ts files for @nx/cypress/plugin",
|
|
54
54
|
"implementation": "./src/migrations/update-17-2-0/add-dev-server-targets-to-cypress-configs"
|
|
55
|
-
},
|
|
56
|
-
"add-nx-cypress-plugin": {
|
|
57
|
-
"version": "17.2.0-beta.0",
|
|
58
|
-
"description": "Add the @nx/cypress/plugin to nx.json plugins",
|
|
59
|
-
"implementation": "./src/migrations/update-17-2-0/add-nx-cypress-plugin"
|
|
60
55
|
}
|
|
61
56
|
},
|
|
62
57
|
"packageJsonUpdates": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/cypress",
|
|
3
|
-
"version": "17.2.0-beta.
|
|
3
|
+
"version": "17.2.0-beta.2",
|
|
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,14 +34,14 @@
|
|
|
34
34
|
"migrations": "./migrations.json"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nx/devkit": "17.2.0-beta.
|
|
38
|
-
"@nx/eslint": "17.2.0-beta.
|
|
39
|
-
"@nx/js": "17.2.0-beta.
|
|
37
|
+
"@nx/devkit": "17.2.0-beta.2",
|
|
38
|
+
"@nx/eslint": "17.2.0-beta.2",
|
|
39
|
+
"@nx/js": "17.2.0-beta.2",
|
|
40
40
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
41
41
|
"detect-port": "^1.5.1",
|
|
42
42
|
"semver": "7.5.3",
|
|
43
43
|
"tslib": "^2.3.0",
|
|
44
|
-
"@nrwl/cypress": "17.2.0-beta.
|
|
44
|
+
"@nrwl/cypress": "17.2.0-beta.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"cypress": ">= 3 < 14"
|
package/src/plugins/plugin.js
CHANGED
|
@@ -61,7 +61,7 @@ function getOutputs(projectRoot, cypressConfig, testingType) {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
const { screenshotsFolder, videosFolder, e2e, component } = cypressConfig;
|
|
64
|
-
const outputs = [
|
|
64
|
+
const outputs = [];
|
|
65
65
|
if (videosFolder) {
|
|
66
66
|
outputs.push(getOutput(videosFolder));
|
|
67
67
|
}
|
|
@@ -92,50 +92,39 @@ function getOutputs(projectRoot, cypressConfig, testingType) {
|
|
|
92
92
|
}
|
|
93
93
|
function buildCypressTargets(configFilePath, projectRoot, options, context) {
|
|
94
94
|
const cypressConfig = getCypressConfig(configFilePath, context);
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
options: {
|
|
99
|
-
cypressConfig: configFilePath,
|
|
100
|
-
},
|
|
95
|
+
const cypressEnv = {
|
|
96
|
+
...cypressConfig.env,
|
|
97
|
+
...cypressConfig.e2e?.env,
|
|
101
98
|
};
|
|
99
|
+
const devServerTargets = cypressEnv?.devServerTargets;
|
|
100
|
+
const relativeConfigPath = (0, path_1.relative)(projectRoot, configFilePath);
|
|
101
|
+
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
102
102
|
const targets = {};
|
|
103
103
|
if ('e2e' in cypressConfig) {
|
|
104
|
-
const e2eTargetDefaults = (0, project_configuration_utils_1.readTargetDefaultsForTarget)(options.targetName, context.nxJsonConfiguration.targetDefaults, '@nx/cypress:cypress');
|
|
105
104
|
targets[options.targetName] = {
|
|
106
|
-
|
|
105
|
+
command: `cypress run --config-file ${relativeConfigPath} --e2e`,
|
|
107
106
|
options: {
|
|
108
|
-
|
|
109
|
-
testingType: 'e2e',
|
|
107
|
+
cwd: projectRoot,
|
|
110
108
|
},
|
|
111
109
|
};
|
|
110
|
+
const e2eTargetDefaults = (0, project_configuration_utils_1.readTargetDefaultsForTarget)(options.targetName, context.nxJsonConfiguration.targetDefaults, 'run-commands');
|
|
112
111
|
if (e2eTargetDefaults?.cache === undefined) {
|
|
113
112
|
targets[options.targetName].cache = true;
|
|
114
113
|
}
|
|
115
114
|
if (e2eTargetDefaults?.inputs === undefined) {
|
|
116
|
-
targets[options.targetName].inputs =
|
|
117
|
-
'production' in namedInputs
|
|
118
|
-
? ['default', '^production']
|
|
119
|
-
: ['default', '^default'];
|
|
115
|
+
targets[options.targetName].inputs = getInputs(namedInputs);
|
|
120
116
|
}
|
|
121
117
|
if (e2eTargetDefaults?.outputs === undefined) {
|
|
122
118
|
targets[options.targetName].outputs = getOutputs(projectRoot, cypressConfig, 'e2e');
|
|
123
119
|
}
|
|
124
|
-
const cypressEnv = {
|
|
125
|
-
...cypressConfig.env,
|
|
126
|
-
...cypressConfig.e2e?.env,
|
|
127
|
-
};
|
|
128
|
-
const devServerTargets = cypressEnv?.devServerTargets;
|
|
129
120
|
if (devServerTargets?.default) {
|
|
130
|
-
targets[options.targetName].options.devServerTarget =
|
|
131
|
-
devServerTargets.default;
|
|
132
121
|
delete devServerTargets.default;
|
|
133
122
|
}
|
|
134
123
|
if (Object.keys(devServerTargets ?? {}).length > 0) {
|
|
135
124
|
targets[options.targetName].configurations ??= {};
|
|
136
125
|
for (const [configuration, devServerTarget] of Object.entries(devServerTargets ?? {})) {
|
|
137
126
|
targets[options.targetName].configurations[configuration] = {
|
|
138
|
-
devServerTarget
|
|
127
|
+
command: `cypress run --config-file ${relativeConfigPath} --e2e --env.devServerTarget ${devServerTarget}`,
|
|
139
128
|
};
|
|
140
129
|
}
|
|
141
130
|
}
|
|
@@ -153,22 +142,15 @@ function buildCypressTargets(configFilePath, projectRoot, options, context) {
|
|
|
153
142
|
const specFiles = (0, workspace_context_1.globWithWorkspaceContext)(context.workspaceRoot, specPatterns, excludeSpecPatterns);
|
|
154
143
|
const dependsOn = [];
|
|
155
144
|
const outputs = getOutputs(projectRoot, cypressConfig, 'e2e');
|
|
156
|
-
const inputs =
|
|
157
|
-
? ['default', '^production']
|
|
158
|
-
: ['default', '^default'];
|
|
145
|
+
const inputs = getInputs(namedInputs);
|
|
159
146
|
for (const file of specFiles) {
|
|
160
|
-
const
|
|
147
|
+
const relativeSpecFilePath = (0, path_1.relative)(projectRoot, file);
|
|
148
|
+
const targetName = options.ciTargetName + '--' + relativeSpecFilePath;
|
|
161
149
|
targets[targetName] = {
|
|
162
|
-
...targets[options.targetName],
|
|
163
150
|
outputs,
|
|
164
151
|
inputs,
|
|
165
152
|
cache: true,
|
|
166
|
-
|
|
167
|
-
options: {
|
|
168
|
-
...targets[options.targetName].options,
|
|
169
|
-
devServerTarget: ciDevServerTarget,
|
|
170
|
-
spec: file,
|
|
171
|
-
},
|
|
153
|
+
command: `cypress run --config-file ${relativeConfigPath} --e2e --env.devServerTarget ${ciDevServerTarget} --spec ${relativeSpecFilePath}`,
|
|
172
154
|
};
|
|
173
155
|
dependsOn.push({
|
|
174
156
|
target: targetName,
|
|
@@ -190,10 +172,9 @@ function buildCypressTargets(configFilePath, projectRoot, options, context) {
|
|
|
190
172
|
const componentTestingTargetDefaults = (0, project_configuration_utils_1.readTargetDefaultsForTarget)(options.componentTestingTargetName, context.nxJsonConfiguration.targetDefaults, '@nx/cypress:cypress');
|
|
191
173
|
// This will not override the e2e target if it is the same
|
|
192
174
|
targets[options.componentTestingTargetName] ??= {
|
|
193
|
-
|
|
175
|
+
command: `cypress open --config-file ${relativeConfigPath} --component`,
|
|
194
176
|
options: {
|
|
195
|
-
|
|
196
|
-
testingType: 'component',
|
|
177
|
+
cwd: projectRoot,
|
|
197
178
|
},
|
|
198
179
|
};
|
|
199
180
|
if (componentTestingTargetDefaults?.cache === undefined) {
|
|
@@ -201,9 +182,7 @@ function buildCypressTargets(configFilePath, projectRoot, options, context) {
|
|
|
201
182
|
}
|
|
202
183
|
if (componentTestingTargetDefaults?.inputs === undefined) {
|
|
203
184
|
targets[options.componentTestingTargetName].inputs =
|
|
204
|
-
|
|
205
|
-
? ['default', '^production']
|
|
206
|
-
: ['default', '^default'];
|
|
185
|
+
getInputs(namedInputs);
|
|
207
186
|
}
|
|
208
187
|
if (componentTestingTargetDefaults?.outputs === undefined) {
|
|
209
188
|
targets[options.componentTestingTargetName].outputs = getOutputs(projectRoot, cypressConfig, 'component');
|
|
@@ -241,3 +220,13 @@ function normalizeOptions(options) {
|
|
|
241
220
|
options.ciTargetName ??= 'e2e-ci';
|
|
242
221
|
return options;
|
|
243
222
|
}
|
|
223
|
+
function getInputs(namedInputs) {
|
|
224
|
+
return [
|
|
225
|
+
...('production' in namedInputs
|
|
226
|
+
? ['default', '^production']
|
|
227
|
+
: ['default', '^default']),
|
|
228
|
+
{
|
|
229
|
+
externalDependencies: ['cypress'],
|
|
230
|
+
},
|
|
231
|
+
];
|
|
232
|
+
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
const plugin_1 = require("../../plugins/plugin");
|
|
5
|
-
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
|
|
6
|
-
const replace_project_configuration_with_plugin_1 = require("@nx/devkit/src/utils/replace-project-configuration-with-plugin");
|
|
7
|
-
async function update(tree) {
|
|
8
|
-
const proj = Object.fromEntries((0, devkit_1.getProjects)(tree).entries());
|
|
9
|
-
const rootMappings = (0, find_project_for_path_1.createProjectRootMappingsFromProjectConfigurations)(proj);
|
|
10
|
-
await (0, replace_project_configuration_with_plugin_1.replaceProjectConfigurationsWithPlugin)(tree, rootMappings, '@nx/cypress/plugin', plugin_1.createNodes, {
|
|
11
|
-
targetName: 'e2e',
|
|
12
|
-
componentTestingTargetName: 'component-test',
|
|
13
|
-
});
|
|
14
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
15
|
-
}
|
|
16
|
-
exports.default = update;
|