@nx/cypress 22.7.1 → 22.7.3
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/package.json +7 -7
- package/src/plugins/plugin.js +35 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/cypress",
|
|
3
|
-
"version": "22.7.
|
|
3
|
+
"version": "22.7.3",
|
|
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": {
|
|
@@ -37,17 +37,17 @@
|
|
|
37
37
|
"migrations": "./migrations.json"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@nx/devkit": "22.7.
|
|
41
|
-
"@nx/eslint": "22.7.
|
|
42
|
-
"@nx/js": "22.7.
|
|
43
|
-
"@phenomnomnominal/tsquery": "~6.
|
|
44
|
-
"detect-port": "^1.
|
|
40
|
+
"@nx/devkit": "22.7.3",
|
|
41
|
+
"@nx/eslint": "22.7.3",
|
|
42
|
+
"@nx/js": "22.7.3",
|
|
43
|
+
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
44
|
+
"detect-port": "^2.1.0",
|
|
45
45
|
"semver": "^7.6.3",
|
|
46
46
|
"tree-kill": "1.2.2",
|
|
47
47
|
"tslib": "^2.3.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"nx": "22.7.
|
|
50
|
+
"nx": "22.7.3"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"cypress": ">= 13 < 16"
|
package/src/plugins/plugin.js
CHANGED
|
@@ -70,47 +70,63 @@ async function createNodesInternal(configFilePath, options, context, pluginCache
|
|
|
70
70
|
function getTargetOutputs(outputs, subfolder) {
|
|
71
71
|
return outputs.map((output) => subfolder ? (0, path_1.join)(output, subfolder) : output);
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
// Normalize a Cypress config folder (e.g. videosFolder, screenshotsFolder) to a
|
|
74
|
+
// project-root-relative path, then append the per-spec subfolder. Cypress
|
|
75
|
+
// resolves relative folders against the project root (cwd), so this keeps the
|
|
76
|
+
// path Cypress writes to in lockstep with what Nx declares as the target's
|
|
77
|
+
// outputs — regardless of whether the user wrote a relative path or computed
|
|
78
|
+
// an absolute one (e.g. via `path.resolve` / `__dirname`).
|
|
79
|
+
function serializeConfigPath(configPath, projectRoot, workspaceRoot, outputSubfolder) {
|
|
80
|
+
if (!configPath) {
|
|
81
|
+
return configPath;
|
|
82
|
+
}
|
|
83
|
+
const fullProjectRoot = (0, path_1.resolve)(workspaceRoot, projectRoot);
|
|
84
|
+
const fullConfigPath = (0, path_1.resolve)(fullProjectRoot, configPath);
|
|
85
|
+
const relativeConfigPath = (0, devkit_1.normalizePath)((0, path_1.relative)(fullProjectRoot, fullConfigPath));
|
|
86
|
+
return (0, devkit_1.normalizePath)((0, path_1.join)(relativeConfigPath, outputSubfolder));
|
|
87
|
+
}
|
|
88
|
+
function getTargetConfig(cypressConfig, projectRoot, workspaceRoot, outputSubfolder, ciBaseUrl) {
|
|
74
89
|
const config = {};
|
|
75
90
|
if (ciBaseUrl) {
|
|
76
91
|
config['baseUrl'] = ciBaseUrl;
|
|
77
92
|
}
|
|
78
93
|
const { screenshotsFolder, videosFolder, e2e, component } = cypressConfig;
|
|
79
94
|
if (videosFolder) {
|
|
80
|
-
config['videosFolder'] = (
|
|
95
|
+
config['videosFolder'] = serializeConfigPath(videosFolder, projectRoot, workspaceRoot, outputSubfolder);
|
|
81
96
|
}
|
|
82
97
|
if (screenshotsFolder) {
|
|
83
|
-
config['screenshotsFolder'] = (
|
|
98
|
+
config['screenshotsFolder'] = serializeConfigPath(screenshotsFolder, projectRoot, workspaceRoot, outputSubfolder);
|
|
84
99
|
}
|
|
85
100
|
if (e2e) {
|
|
86
101
|
config['e2e'] = {};
|
|
87
102
|
if (e2e.videosFolder) {
|
|
88
|
-
config['e2e']['videosFolder'] = (
|
|
103
|
+
config['e2e']['videosFolder'] = serializeConfigPath(e2e.videosFolder, projectRoot, workspaceRoot, outputSubfolder);
|
|
89
104
|
}
|
|
90
105
|
if (e2e.screenshotsFolder) {
|
|
91
|
-
config['e2e']['screenshotsFolder'] = (
|
|
106
|
+
config['e2e']['screenshotsFolder'] = serializeConfigPath(e2e.screenshotsFolder, projectRoot, workspaceRoot, outputSubfolder);
|
|
92
107
|
}
|
|
93
108
|
}
|
|
94
109
|
if (component) {
|
|
95
110
|
config['component'] = {};
|
|
96
111
|
if (component.videosFolder) {
|
|
97
|
-
config['component']['videosFolder'] = (
|
|
112
|
+
config['component']['videosFolder'] = serializeConfigPath(component.videosFolder, projectRoot, workspaceRoot, outputSubfolder);
|
|
98
113
|
}
|
|
99
114
|
if (component.screenshotsFolder) {
|
|
100
|
-
config['component']['screenshotsFolder'] = (
|
|
115
|
+
config['component']['screenshotsFolder'] = serializeConfigPath(component.screenshotsFolder, projectRoot, workspaceRoot, outputSubfolder);
|
|
101
116
|
}
|
|
102
117
|
}
|
|
103
118
|
// Stringify twice to escape the quotes.
|
|
104
119
|
return JSON.stringify(JSON.stringify(config));
|
|
105
120
|
}
|
|
106
|
-
function getOutputs(projectRoot, cypressConfig, testingType) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return (0, devkit_1.joinPathFragments)('{
|
|
121
|
+
function getOutputs(projectRoot, cypressConfig, testingType, workspaceRoot) {
|
|
122
|
+
const fullProjectRoot = (0, path_1.resolve)(workspaceRoot, projectRoot);
|
|
123
|
+
function getOutput(outputPath) {
|
|
124
|
+
const fullPath = (0, path_1.resolve)(fullProjectRoot, outputPath);
|
|
125
|
+
const relativeToProjectRoot = (0, devkit_1.normalizePath)((0, path_1.relative)(fullProjectRoot, fullPath));
|
|
126
|
+
if (relativeToProjectRoot.startsWith('..')) {
|
|
127
|
+
return (0, devkit_1.joinPathFragments)('{workspaceRoot}', (0, path_1.relative)(workspaceRoot, fullPath));
|
|
113
128
|
}
|
|
129
|
+
return (0, devkit_1.joinPathFragments)('{projectRoot}', relativeToProjectRoot);
|
|
114
130
|
}
|
|
115
131
|
const { screenshotsFolder, videosFolder, e2e, component } = cypressConfig;
|
|
116
132
|
const outputs = [];
|
|
@@ -164,7 +180,7 @@ async function buildCypressTargets(configFilePath, projectRoot, options, context
|
|
|
164
180
|
},
|
|
165
181
|
cache: true,
|
|
166
182
|
inputs: getInputs(namedInputs),
|
|
167
|
-
outputs: getOutputs(projectRoot, cypressConfig, 'e2e'),
|
|
183
|
+
outputs: getOutputs(projectRoot, cypressConfig, 'e2e', context.workspaceRoot),
|
|
168
184
|
metadata: {
|
|
169
185
|
technologies: ['cypress'],
|
|
170
186
|
description: 'Runs Cypress Tests',
|
|
@@ -209,7 +225,7 @@ async function buildCypressTargets(configFilePath, projectRoot, options, context
|
|
|
209
225
|
const { specFiles, specPatterns, excludeSpecPatterns } = await getSpecFilesAndPatternsForTestType(cypressConfig, 'e2e', context.workspaceRoot, projectRoot);
|
|
210
226
|
const ciBaseUrl = pluginPresetOptions?.ciBaseUrl;
|
|
211
227
|
const dependsOn = [];
|
|
212
|
-
const outputs = getOutputs(projectRoot, cypressConfig, 'e2e');
|
|
228
|
+
const outputs = getOutputs(projectRoot, cypressConfig, 'e2e', context.workspaceRoot);
|
|
213
229
|
const inputs = getInputs(namedInputs);
|
|
214
230
|
const groupName = 'E2E (CI)';
|
|
215
231
|
metadata = { targetGroups: { [groupName]: [] } };
|
|
@@ -239,7 +255,7 @@ async function buildCypressTargets(configFilePath, projectRoot, options, context
|
|
|
239
255
|
outputs: getTargetOutputs(outputs, outputSubfolder),
|
|
240
256
|
inputs,
|
|
241
257
|
cache: true,
|
|
242
|
-
command: `cypress run --env webServerCommand="${ciWebServerCommand}" --spec ${relativeSpecFilePath} --config=${getTargetConfig(cypressConfig, outputSubfolder, ciBaseUrl)}`,
|
|
258
|
+
command: `cypress run --env webServerCommand="${ciWebServerCommand}" --spec ${relativeSpecFilePath} --config=${getTargetConfig(cypressConfig, projectRoot, context.workspaceRoot, outputSubfolder, ciBaseUrl)}`,
|
|
243
259
|
options: {
|
|
244
260
|
cwd: projectRoot,
|
|
245
261
|
env: { TS_NODE_COMPILER_OPTIONS: tsNodeCompilerOptions },
|
|
@@ -257,7 +273,6 @@ async function buildCypressTargets(configFilePath, projectRoot, options, context
|
|
|
257
273
|
};
|
|
258
274
|
dependsOn.push({
|
|
259
275
|
target: targetName,
|
|
260
|
-
projects: 'self',
|
|
261
276
|
params: 'forward',
|
|
262
277
|
options: 'forward',
|
|
263
278
|
});
|
|
@@ -299,7 +314,7 @@ async function buildCypressTargets(configFilePath, projectRoot, options, context
|
|
|
299
314
|
}
|
|
300
315
|
if ('component' in cypressConfig) {
|
|
301
316
|
const inputs = getInputs(namedInputs);
|
|
302
|
-
const outputs = getOutputs(projectRoot, cypressConfig, 'component');
|
|
317
|
+
const outputs = getOutputs(projectRoot, cypressConfig, 'component', context.workspaceRoot);
|
|
303
318
|
// This will not override the e2e target if it is the same
|
|
304
319
|
targets[options.componentTestingTargetName] ??= {
|
|
305
320
|
command: `cypress run --component`,
|
|
@@ -351,7 +366,7 @@ async function buildCypressTargets(configFilePath, projectRoot, options, context
|
|
|
351
366
|
outputs: getTargetOutputs(outputs, outputSubfolder),
|
|
352
367
|
inputs,
|
|
353
368
|
cache: true,
|
|
354
|
-
command: `cypress run --component --spec ${relativeSpecFilePath} --config=${getTargetConfig(cypressConfig, outputSubfolder)}`,
|
|
369
|
+
command: `cypress run --component --spec ${relativeSpecFilePath} --config=${getTargetConfig(cypressConfig, projectRoot, context.workspaceRoot, outputSubfolder)}`,
|
|
355
370
|
options: {
|
|
356
371
|
cwd: projectRoot,
|
|
357
372
|
env: { TS_NODE_COMPILER_OPTIONS: tsNodeCompilerOptions },
|
|
@@ -373,7 +388,6 @@ async function buildCypressTargets(configFilePath, projectRoot, options, context
|
|
|
373
388
|
};
|
|
374
389
|
dependsOn.push({
|
|
375
390
|
target: targetName,
|
|
376
|
-
projects: 'self',
|
|
377
391
|
params: 'forward',
|
|
378
392
|
options: 'forward',
|
|
379
393
|
});
|