Skip to content

Commit 9ce301f

Browse files
authored
fix(testing): fix cypress and playwright atomized targetDefaults so they match correctly (#30717)
Currently, we provide `targetDefaults` for atomized targets (e.g. `e2e-ci`) with a glob pattern that may not match nested paths. i.e. ``` "e2e-ci--**/*": { "dependsOn": [ "^build", ], }, ``` The `e2e-ci--**/*` pattern should be `e2e-ci--**/**`. <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior The generated `e2e-ci` pattern in `nx.json` does not match nested paths for split tasks. ## Expected Behavior The generated `e2e-ci` pattern should apply to all split tasks. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #28842
1 parent be32662 commit 9ce301f

File tree

12 files changed

+44
-44
lines changed

12 files changed

+44
-44
lines changed

packages/angular/src/generators/application/application.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ describe('app', () => {
605605
},
606606
]
607607
`);
608-
expect(nxJson.targetDefaults['e2e-ci--**/*']).toMatchInlineSnapshot(`
608+
expect(nxJson.targetDefaults['e2e-ci--**/**']).toMatchInlineSnapshot(`
609609
{
610610
"dependsOn": [
611611
"^build",

packages/cypress/src/migrations/update-19-6-0/add-e2e-ci-target-defaults.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('add-e2e-ci-target-defaults', () => {
7777
"build": {
7878
"cache": true,
7979
},
80-
"e2e-ci--**/*": {
80+
"e2e-ci--**/**": {
8181
"dependsOn": [
8282
"^build",
8383
],
@@ -114,7 +114,7 @@ describe('add-e2e-ci-target-defaults', () => {
114114
"build": {
115115
"cache": true,
116116
},
117-
"e2e-ci--**/*": {
117+
"e2e-ci--**/**": {
118118
"dependsOn": [
119119
"build",
120120
],
@@ -165,12 +165,12 @@ describe('add-e2e-ci-target-defaults', () => {
165165
"build": {
166166
"cache": true,
167167
},
168-
"cypress:e2e-ci--**/*": {
168+
"cypress:e2e-ci--**/**": {
169169
"dependsOn": [
170170
"^build",
171171
],
172172
},
173-
"e2e-ci--**/*": {
173+
"e2e-ci--**/**": {
174174
"dependsOn": [
175175
"^build",
176176
],
@@ -220,7 +220,7 @@ describe('add-e2e-ci-target-defaults', () => {
220220
"build": {
221221
"cache": true,
222222
},
223-
"cypress:e2e-ci--**/*": {
223+
"cypress:e2e-ci--**/**": {
224224
"dependsOn": [
225225
"^build",
226226
"^bundle",

packages/devkit/src/generators/target-defaults-utils.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('target-defaults-utils', () => {
1717
jest.resetModules();
1818
});
1919

20-
it('should add e2e-ci--**/* target default for e2e plugin for specified build target when it does not exist', async () => {
20+
it('should add e2e-ci--**/** target default for e2e plugin for specified build target when it does not exist', async () => {
2121
// ARRANGE
2222
const nxJson = readNxJson(tree);
2323
nxJson.plugins ??= [];
@@ -43,7 +43,7 @@ describe('target-defaults-utils', () => {
4343

4444
// ASSERT
4545
const newNxJson = readNxJson(tree);
46-
expect(newNxJson.targetDefaults['e2e-ci--**/*']).toMatchInlineSnapshot(`
46+
expect(newNxJson.targetDefaults['e2e-ci--**/**']).toMatchInlineSnapshot(`
4747
{
4848
"dependsOn": [
4949
"^build",
@@ -52,7 +52,7 @@ describe('target-defaults-utils', () => {
5252
`);
5353
});
5454

55-
it('should update existing e2e-ci--**/* target default for e2e plugin for specified build target when it does not exist in dependsOn', async () => {
55+
it('should update existing e2e-ci--**/** target default for e2e plugin for specified build target when it does not exist in dependsOn', async () => {
5656
// ARRANGE
5757
const nxJson = readNxJson(tree);
5858
nxJson.plugins ??= [];
@@ -64,7 +64,7 @@ describe('target-defaults-utils', () => {
6464
},
6565
});
6666
nxJson.targetDefaults ??= {};
67-
nxJson.targetDefaults['e2e-ci--**/*'] = {
67+
nxJson.targetDefaults['e2e-ci--**/**'] = {
6868
dependsOn: ['^build'],
6969
};
7070
updateNxJson(tree, nxJson);
@@ -82,7 +82,7 @@ describe('target-defaults-utils', () => {
8282

8383
// ASSERT
8484
const newNxJson = readNxJson(tree);
85-
expect(newNxJson.targetDefaults['e2e-ci--**/*']).toMatchInlineSnapshot(`
85+
expect(newNxJson.targetDefaults['e2e-ci--**/**']).toMatchInlineSnapshot(`
8686
{
8787
"dependsOn": [
8888
"^build",
@@ -104,7 +104,7 @@ describe('target-defaults-utils', () => {
104104
},
105105
});
106106
nxJson.targetDefaults ??= {};
107-
nxJson.targetDefaults['e2e-ci--**/*'] = {
107+
nxJson.targetDefaults['e2e-ci--**/**'] = {
108108
dependsOn: ['^build'],
109109
};
110110
updateNxJson(tree, nxJson);
@@ -122,14 +122,14 @@ describe('target-defaults-utils', () => {
122122

123123
// ASSERT
124124
const newNxJson = readNxJson(tree);
125-
expect(newNxJson.targetDefaults['e2e-ci--**/*']).toMatchInlineSnapshot(`
125+
expect(newNxJson.targetDefaults['e2e-ci--**/**']).toMatchInlineSnapshot(`
126126
{
127127
"dependsOn": [
128128
"^build",
129129
],
130130
}
131131
`);
132-
expect(newNxJson.targetDefaults['cypress:e2e-ci--**/*'])
132+
expect(newNxJson.targetDefaults['cypress:e2e-ci--**/**'])
133133
.toMatchInlineSnapshot(`
134134
{
135135
"dependsOn": [
@@ -139,7 +139,7 @@ describe('target-defaults-utils', () => {
139139
`);
140140
});
141141

142-
it('should not add additional e2e-ci--**/* target default for e2e plugin when it already exists with build target', async () => {
142+
it('should not add additional e2e-ci--**/** target default for e2e plugin when it already exists with build target', async () => {
143143
// ARRANGE
144144
const nxJson = readNxJson(tree);
145145
nxJson.plugins ??= [];
@@ -151,7 +151,7 @@ describe('target-defaults-utils', () => {
151151
},
152152
});
153153
nxJson.targetDefaults ??= {};
154-
nxJson.targetDefaults['e2e-ci--**/*'] = {
154+
nxJson.targetDefaults['e2e-ci--**/**'] = {
155155
dependsOn: ['^build'],
156156
};
157157
updateNxJson(tree, nxJson);
@@ -174,7 +174,7 @@ describe('target-defaults-utils', () => {
174174
"build": {
175175
"cache": true,
176176
},
177-
"e2e-ci--**/*": {
177+
"e2e-ci--**/**": {
178178
"dependsOn": [
179179
"^build",
180180
],
@@ -290,7 +290,7 @@ describe('target-defaults-utils', () => {
290290

291291
// ASSERT
292292
const newNxJson = readNxJson(tree);
293-
expect(newNxJson.targetDefaults['cypress:e2e-ci--**/*'])
293+
expect(newNxJson.targetDefaults['cypress:e2e-ci--**/**'])
294294
.toMatchInlineSnapshot(`
295295
{
296296
"dependsOn": [
@@ -335,7 +335,7 @@ describe('target-defaults-utils', () => {
335335

336336
// ASSERT
337337
const newNxJson = readNxJson(tree);
338-
expect(newNxJson.targetDefaults['cypress:e2e-ci--**/*'])
338+
expect(newNxJson.targetDefaults['cypress:e2e-ci--**/**'])
339339
.toMatchInlineSnapshot(`
340340
{
341341
"dependsOn": [
@@ -365,7 +365,7 @@ describe('target-defaults-utils', () => {
365365

366366
// ASSERT
367367
const newNxJson = readNxJson(tree);
368-
expect(newNxJson.targetDefaults['e2e-ci--**/*']).toMatchInlineSnapshot(`
368+
expect(newNxJson.targetDefaults['e2e-ci--**/**']).toMatchInlineSnapshot(`
369369
{
370370
"dependsOn": [
371371
"^build",

packages/devkit/src/generators/target-defaults-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export async function addE2eCiTargetDefaults(
8181
? 'e2e-ci'
8282
: (foundPluginForApplication.options as any)?.ciTargetName ?? 'e2e-ci';
8383

84-
const ciTargetNameGlob = `${ciTargetName}--**/*`;
84+
const ciTargetNameGlob = `${ciTargetName}--**/**`;
8585
nxJson.targetDefaults ??= {};
8686
const e2eCiTargetDefaults = nxJson.targetDefaults[ciTargetNameGlob];
8787
if (!e2eCiTargetDefaults) {

packages/expo/src/generators/application/application.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ describe('app', () => {
295295

296296
// ASSERT
297297
const nxJson = readNxJson(appTree);
298-
expect(nxJson.targetDefaults['e2e-ci--**/*']).toMatchInlineSnapshot(`
298+
expect(nxJson.targetDefaults['e2e-ci--**/**']).toMatchInlineSnapshot(`
299299
{
300300
"dependsOn": [
301301
"^export",
@@ -320,7 +320,7 @@ describe('app', () => {
320320

321321
// ASSERT
322322
const nxJson = readNxJson(appTree);
323-
expect(nxJson.targetDefaults['e2e-ci--**/*']).toMatchInlineSnapshot(`
323+
expect(nxJson.targetDefaults['e2e-ci--**/**']).toMatchInlineSnapshot(`
324324
{
325325
"dependsOn": [
326326
"^export",

packages/next/src/generators/application/application.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ describe('app', () => {
576576
e2eTestRunner: 'cypress',
577577
addPlugin: true,
578578
});
579-
expect(readNxJson(tree).targetDefaults['e2e-ci--**/*'])
579+
expect(readNxJson(tree).targetDefaults['e2e-ci--**/**'])
580580
.toMatchInlineSnapshot(`
581581
{
582582
"dependsOn": [
@@ -597,7 +597,7 @@ describe('app', () => {
597597
e2eTestRunner: 'playwright',
598598
addPlugin: true,
599599
});
600-
expect(readNxJson(tree).targetDefaults['e2e-ci--**/*'])
600+
expect(readNxJson(tree).targetDefaults['e2e-ci--**/**'])
601601
.toMatchInlineSnapshot(`
602602
{
603603
"dependsOn": [

packages/nuxt/src/generators/application/application.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ describe('app', () => {
163163
nxJson.plugins.find((p) => p.plugin === '@nx/vite/plugin')
164164
)
165165
);
166-
expect(nxJson.targetDefaults['e2e-ci--**/*']).toMatchSnapshot();
166+
expect(nxJson.targetDefaults['e2e-ci--**/**']).toMatchSnapshot();
167167
});
168168
});
169169

packages/playwright/src/migrations/update-19-6-0/add-e2e-ci-target-defaults.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('add-e2e-ci-target-defaults', () => {
7777
"build": {
7878
"cache": true,
7979
},
80-
"e2e-ci--**/*": {
80+
"e2e-ci--**/**": {
8181
"dependsOn": [
8282
"^build",
8383
],
@@ -144,7 +144,7 @@ export default defineConfig({
144144
"build": {
145145
"cache": true,
146146
},
147-
"e2e-ci--**/*": {
147+
"e2e-ci--**/**": {
148148
"dependsOn": [
149149
"^build",
150150
],
@@ -196,15 +196,15 @@ export default defineConfig({
196196
"build": {
197197
"cache": true,
198198
},
199-
"e2e-ci--**/*": {
199+
"e2e-ci--**/**": {
200200
"dependsOn": [
201201
"^build",
202202
],
203203
},
204204
"lint": {
205205
"cache": true,
206206
},
207-
"playwright:e2e-ci--**/*": {
207+
"playwright:e2e-ci--**/**": {
208208
"dependsOn": [
209209
"^build",
210210
],
@@ -254,7 +254,7 @@ export default defineConfig({
254254
"lint": {
255255
"cache": true,
256256
},
257-
"playwright:e2e-ci--**/*": {
257+
"playwright:e2e-ci--**/**": {
258258
"dependsOn": [
259259
"^build",
260260
"^bundle",

packages/react/src/generators/application/application.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ describe('app', () => {
13641364
nxJson = readNxJson(tree);
13651365
expect(nxJson.targetDefaults).toMatchInlineSnapshot(`
13661366
{
1367-
"e2e-ci--**/*": {
1367+
"e2e-ci--**/**": {
13681368
"dependsOn": [
13691369
"^build",
13701370
],
@@ -1393,7 +1393,7 @@ describe('app', () => {
13931393
nxJson = readNxJson(tree);
13941394
expect(nxJson.targetDefaults).toMatchInlineSnapshot(`
13951395
{
1396-
"e2e-ci--**/*": {
1396+
"e2e-ci--**/**": {
13971397
"dependsOn": [
13981398
"^build",
13991399
],
@@ -1430,7 +1430,7 @@ describe('app', () => {
14301430
nxJson = readNxJson(tree);
14311431
expect(nxJson.targetDefaults).toMatchInlineSnapshot(`
14321432
{
1433-
"e2e-ci--**/*": {
1433+
"e2e-ci--**/**": {
14341434
"dependsOn": [
14351435
"^build-base",
14361436
],

packages/remix/src/generators/application/application.impl.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe('Remix Application', () => {
178178
expectTargetsToBeCorrect(tree, '.');
179179

180180
expect(tree.read('e2e/cypress.config.ts', 'utf-8')).toMatchSnapshot();
181-
expect(readNxJson(tree).targetDefaults['e2e-ci--**/*'])
181+
expect(readNxJson(tree).targetDefaults['e2e-ci--**/**'])
182182
.toMatchInlineSnapshot(`
183183
{
184184
"dependsOn": [
@@ -206,14 +206,14 @@ describe('Remix Application', () => {
206206
expectTargetsToBeCorrect(tree, '.');
207207

208208
expect(tree.read('e2e/playwright.config.ts', 'utf-8')).toMatchSnapshot();
209-
expect(readNxJson(tree).targetDefaults['e2e-ci--**/*'])
209+
expect(readNxJson(tree).targetDefaults['e2e-ci--**/**'])
210210
.toMatchInlineSnapshot(`
211-
{
212-
"dependsOn": [
213-
"^build",
214-
],
215-
}
216-
`);
211+
{
212+
"dependsOn": [
213+
"^build",
214+
],
215+
}
216+
`);
217217
});
218218
});
219219

0 commit comments

Comments
 (0)