Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(testing): adding e2e projects should register e2e-ci targetDefaults #27185

Merged
merged 22 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9ff004d
fix(vite): add migration to add dependsOn for preview
Coly010 Aug 1, 2024
08c45a3
fix(testing): add migration for cypress should use preview for vite a…
Coly010 Aug 1, 2024
6954633
fix(testing): add migration for playwright to use serve-static or pre…
Coly010 Aug 1, 2024
b148981
chore(testing): point migrations to 19.6 release
Coly010 Aug 2, 2024
15e6389
feat(devkit): add util for adding e2e-ci target defaults
Coly010 Jul 29, 2024
2edfb1a
fix(angular): add e2e-ci target defaults when e2e project added
Coly010 Jul 29, 2024
d7a05b3
feat(devkit): add util for finding the plugin registration matching a…
Coly010 Jul 29, 2024
a52950f
fix(expo): application generator should add e2e-ci target defaults
Coly010 Jul 29, 2024
49a7091
fix(nextjs): application generator should add e2e-ci target defaults
Coly010 Jul 29, 2024
93bc523
chore(repo): add tsconfig path mapping for @nx/playwright/*
Coly010 Jul 29, 2024
f8fbe52
fix(nuxt): add e2e-ci target defaults
Coly010 Jul 29, 2024
b309ea0
fix(nuxt): find correct config file for matching plugin
Coly010 Jul 30, 2024
3a0c06d
fix(react): application generator should add e2e-ci target defaults
Coly010 Jul 30, 2024
a3b8761
fix(remix): application generator should add e2e-ci target defaults
Coly010 Jul 30, 2024
5336749
fix(vue): application generator should add e2e-ci target defaults
Coly010 Jul 30, 2024
0d90aad
fix(web): application generator should add e2e-ci target defaults
Coly010 Jul 30, 2024
b0dbf5c
fix(repo): add missing snapshots
Coly010 Jul 30, 2024
42f1ed3
feat(testing): add cypress migration to add e2e-ci targetDefaults
Coly010 Jul 31, 2024
c9c6731
fix(testing): add migration for playwright e2e-ci
Coly010 Aug 2, 2024
4dcc4f2
fix(testing): playwright add e2ecidefault should handle no matching p…
Coly010 Aug 5, 2024
05b8970
fix(testing): cypress add e2ecidefault should handle no matching plugins
Coly010 Aug 5, 2024
01b7536
chore(nextjs): use uniq for test
Coly010 Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ describe('app', () => {
it('should add eslint plugin and no lint target to e2e project', async () => {
await generateApp(appTree, 'my-app', { linter: Linter.EsLint });

expect(readNxJson(appTree).plugins).toMatchInlineSnapshot(`
const nxJson = readNxJson(appTree);
expect(nxJson.plugins).toMatchInlineSnapshot(`
[
{
"options": {
Expand All @@ -588,6 +589,13 @@ describe('app', () => {
},
]
`);
expect(nxJson.targetDefaults['e2e-ci--**/*']).toMatchInlineSnapshot(`
{
"dependsOn": [
"^build",
],
}
`);
expect(
readProjectConfiguration(appTree, 'my-app-e2e').targets.lint
).toBeUndefined();
Expand Down
17 changes: 17 additions & 0 deletions packages/angular/src/generators/application/lib/add-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { nxVersion } from '../../../utils/versions';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
import type { NormalizedSchema } from './normalized-schema';
import { addE2eCiTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';

export async function addE2e(tree: Tree, options: NormalizedSchema) {
// since e2e are separate projects, default to adding plugins
Expand Down Expand Up @@ -45,6 +46,14 @@ export async function addE2e(tree: Tree, options: NormalizedSchema) {
rootProject: options.rootProject,
addPlugin,
});
if (addPlugin) {
await addE2eCiTargetDefaults(
tree,
'@nx/cypress/plugin',
'^build',
joinPathFragments(options.e2eProjectRoot, 'cypress.config.ts')
);
}
} else if (options.e2eTestRunner === 'playwright') {
const { configurationGenerator } = ensurePackage<
typeof import('@nx/playwright')
Expand All @@ -71,6 +80,14 @@ export async function addE2e(tree: Tree, options: NormalizedSchema) {
rootProject: options.rootProject,
addPlugin,
});
if (addPlugin) {
await addE2eCiTargetDefaults(
tree,
'@nx/playwright/plugin',
'^build',
joinPathFragments(options.e2eProjectRoot, 'playwright.config.ts')
);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { addProjectConfiguration, joinPathFragments, Tree } from '@nx/devkit';
import type { AngularProjectConfiguration } from '../../../utils/types';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
import type { NormalizedSchema } from './normalized-schema';
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/add-build-target-defaults';
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';

export function createProject(tree: Tree, options: NormalizedSchema) {
const { major: angularMajorVersion } = getInstalledAngularVersionInfo(tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Tree } from '@nx/devkit';
import { addProjectConfiguration, joinPathFragments } from '@nx/devkit';
import type { AngularProjectConfiguration } from '../../../utils/types';
import type { NormalizedSchema } from './normalized-schema';
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/add-build-target-defaults';
import { addBuildTargetDefaults } from '@nx/devkit/src/generators/target-defaults-utils';

export function addProject(
tree: Tree,
Expand Down
6 changes: 6 additions & 0 deletions packages/cypress/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"version": "19.6.0-beta.0",
"description": "Update ciWebServerCommand to use previewTargetName if Vite is detected for the application.",
"implementation": "./src/migrations/update-19-6-0/update-ci-webserver-for-vite"
},
"update-19-6-0-add-e2e-ci-target-defaults": {
"cli": "nx",
"version": "19.6.0-beta.0",
"description": "Add inferred ciTargetNames to targetDefaults with dependsOn to ensure dependent application builds are scheduled before atomized tasks.",
"implementation": "./src/migrations/update-19-6-0/add-e2e-ci-target-defaults"
}
},
"packageJsonUpdates": {
Expand Down
Loading