Skip to content

Commit dfd7241

Browse files
authored
fix(testing): adding e2e projects should register e2e-ci targetDefaults (#27185)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- 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 <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
1 parent e74db49 commit dfd7241

File tree

44 files changed

+2425
-82
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2425
-82
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ describe('app', () => {
569569
it('should add eslint plugin and no lint target to e2e project', async () => {
570570
await generateApp(appTree, 'my-app', { linter: Linter.EsLint });
571571

572-
expect(readNxJson(appTree).plugins).toMatchInlineSnapshot(`
572+
const nxJson = readNxJson(appTree);
573+
expect(nxJson.plugins).toMatchInlineSnapshot(`
573574
[
574575
{
575576
"options": {
@@ -588,6 +589,13 @@ describe('app', () => {
588589
},
589590
]
590591
`);
592+
expect(nxJson.targetDefaults['e2e-ci--**/*']).toMatchInlineSnapshot(`
593+
{
594+
"dependsOn": [
595+
"^build",
596+
],
597+
}
598+
`);
591599
expect(
592600
readProjectConfiguration(appTree, 'my-app-e2e').targets.lint
593601
).toBeUndefined();

packages/angular/src/generators/application/lib/add-e2e.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import { nxVersion } from '../../../utils/versions';
1313
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
1414
import type { NormalizedSchema } from './normalized-schema';
15+
import { addE2eCiTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';
1516

1617
export async function addE2e(tree: Tree, options: NormalizedSchema) {
1718
// since e2e are separate projects, default to adding plugins
@@ -45,6 +46,14 @@ export async function addE2e(tree: Tree, options: NormalizedSchema) {
4546
rootProject: options.rootProject,
4647
addPlugin,
4748
});
49+
if (addPlugin) {
50+
await addE2eCiTargetDefaults(
51+
tree,
52+
'@nx/cypress/plugin',
53+
'^build',
54+
joinPathFragments(options.e2eProjectRoot, 'cypress.config.ts')
55+
);
56+
}
4857
} else if (options.e2eTestRunner === 'playwright') {
4958
const { configurationGenerator } = ensurePackage<
5059
typeof import('@nx/playwright')
@@ -71,6 +80,14 @@ export async function addE2e(tree: Tree, options: NormalizedSchema) {
7180
rootProject: options.rootProject,
7281
addPlugin,
7382
});
83+
if (addPlugin) {
84+
await addE2eCiTargetDefaults(
85+
tree,
86+
'@nx/playwright/plugin',
87+
'^build',
88+
joinPathFragments(options.e2eProjectRoot, 'playwright.config.ts')
89+
);
90+
}
7491
}
7592
}
7693

packages/angular/src/generators/application/lib/create-project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { addProjectConfiguration, joinPathFragments, Tree } from '@nx/devkit';
22
import type { AngularProjectConfiguration } from '../../../utils/types';
33
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
44
import type { NormalizedSchema } from './normalized-schema';
5-
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/add-build-target-defaults';
5+
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';
66

77
export function createProject(tree: Tree, options: NormalizedSchema) {
88
const { major: angularMajorVersion } = getInstalledAngularVersionInfo(tree);

packages/angular/src/generators/library/lib/add-project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Tree } from '@nx/devkit';
22
import { addProjectConfiguration, joinPathFragments } from '@nx/devkit';
33
import type { AngularProjectConfiguration } from '../../../utils/types';
44
import type { NormalizedSchema } from './normalized-schema';
5-
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/add-build-target-defaults';
5+
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';
66

77
export function addProject(
88
tree: Tree,

packages/cypress/migrations.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
"version": "19.6.0-beta.0",
3636
"description": "Update ciWebServerCommand to use previewTargetName if Vite is detected for the application.",
3737
"implementation": "./src/migrations/update-19-6-0/update-ci-webserver-for-vite"
38+
},
39+
"update-19-6-0-add-e2e-ci-target-defaults": {
40+
"cli": "nx",
41+
"version": "19.6.0-beta.0",
42+
"description": "Add inferred ciTargetNames to targetDefaults with dependsOn to ensure dependent application builds are scheduled before atomized tasks.",
43+
"implementation": "./src/migrations/update-19-6-0/add-e2e-ci-target-defaults"
3844
}
3945
},
4046
"packageJsonUpdates": {

0 commit comments

Comments
 (0)