Skip to content

feat(testing): run generated playwright e2e against the dev server locally and a production build in CI - #37121

Open
FrozenPandaz wants to merge 8 commits into
masterfrom
feat/playwright-dev-server-locally
Open

FrozenPandaz wants to merge 8 commits into
masterfrom
feat/playwright-dev-server-locally

Conversation

@FrozenPandaz

@FrozenPandaz FrozenPandaz commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Stacked on #37119 (fix/skip-nx-console-check-without-tty), which is stacked on #35964. Review those first.

The Cypress half was split into its own PR — see Why Playwright only below.

Current Behavior

Generated e2e projects pick their web server differently per runner:

nx e2e locally nx e2e in CI nx e2e-ci
Cypress dev server dev server serve-static
Playwright serve-static serve-static serve-static

The Playwright config has a single webServer.command, so each generator has to choose one server for every context. React, Vue, Web, Expo, Nuxt and Remix pass the production server there, so local e2e never runs against the dev server — you rebuild on every change. Next and Angular pass the dev server, so they never exercise a production build in CI.

Expected Behavior

The generated Playwright config decides based on the CI environment variable: the dev server locally, the production build in CI. The plugin already evaluates the config, so the inferred serve dependency follows automatically.

nx e2e locally nx e2e in CI nx e2e-ci
Cypress dev server dev server serve-static
Playwright dev server serve-static serve-static
  • @nx/playwright:configuration accepts ciWebServerCommand and ciWebServerAddress. When they differ from the local server the config switches on CI; when they match, it is generated exactly as before.
  • The React, Vue, Web, Next, Nuxt, Expo and Remix application generators pass both the dev and the production server.
  • Angular deliberately stays on the dev server in both contexts: its rspack Module Federation host does not meet its own production budget, so a serve-static run in CI fails the build.
  • The Playwright introduction page documents the two new options and the generated CI switch.

Only newly generated projects change; existing configs keep working as they are.

Why Playwright only

Cypress does not have this problem. The Cypress plugin already derives the atomized e2e-ci--* targets from ciWebServerCommand, so it can express both servers without consulting the environment: nx e2e uses the dev server, e2e-ci--* uses the production build, and CI runs the latter. Playwright needed the CI switch because its single webServer block is the only place to express the difference.

An earlier revision of this PR applied the same switch to webServerCommands.default in the generated cypress.config. That regressed the Angular Module Federation e2e suites: in CI the plain e2e target started serve-static, which serves only the host's built files, so the host could never fetch its remote's remoteEntry and the remote's markup never rendered. Those commits were moved to a separate branch and will be reconsidered on their own.

Related Issue(s)

N/A


View Polygraph session ↗

@nx-cloud

nx-cloud Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 1da22c4

Command Status Duration Result
nx affected --targets=lint,oxlint,test,build,e2... ❌ Failed 52m 47s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 1m 2s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 16s View ↗
nx-cloud record -- nx format:check ✅ Succeeded <1s View ↗
nx affected -t e2e-macos-local --parallel=2 --b... ✅ Succeeded 51m 49s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-21 23:01:07 UTC

@FrozenPandaz
FrozenPandaz added this pull request to stack #37120 September 19, 2026 15:51
@netlify

netlify Bot commented Sep 19, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 1da22c4
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6ab1a88326bdc0000783a020
😎 Deploy Preview https://deploy-preview-37121--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Sep 19, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 1da22c4
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6ab1a883b514ee0008327089
😎 Deploy Preview https://deploy-preview-37121--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@FrozenPandaz
FrozenPandaz force-pushed the feat/playwright-dev-server-locally branch from 5a8400f to 7c9db15 Compare September 19, 2026 15:54
FrozenPandaz added a commit that referenced this pull request Sep 19, 2026
newProject moved the built workspace to the backup and copied it back out, then
ran a second pnpm install to repair the links that copy had just broken. Copy to
the backup and rename the original into place instead: the first project is then
the workspace pnpm built, whose links were never broken, so the repair install is
only needed for later suites that do copy from the backup.

Same number of full copies as before -- the move and the copy swap places. The
saving is the reinstall, which was ~12s locally.

Idea from Jason via a parallel session investigating newProject overhead (#37121).
FrozenPandaz added a commit that referenced this pull request Sep 19, 2026
newProject moved the built workspace to the backup and copied it back out, then
ran a second pnpm install to repair the links that copy had just broken. Copy to
the backup and rename the original into place instead: the first project is then
the workspace pnpm built, whose links were never broken, so the repair install is
only needed for later suites that do copy from the backup.

Same number of full copies as before -- the move and the copy swap places. The
saving is the reinstall, which was ~12s locally.

Idea from Jason via a parallel session investigating newProject overhead (#37121).
@FrozenPandaz
FrozenPandaz force-pushed the feat/playwright-dev-server-locally branch from b2a582b to d803b8c Compare September 19, 2026 17:24
@FrozenPandaz
FrozenPandaz force-pushed the feat/playwright-dev-server-locally branch 2 times, most recently from 81253e8 to 4f483ae Compare September 19, 2026 17:46
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@FrozenPandaz
FrozenPandaz force-pushed the feat/playwright-dev-server-locally branch from 4f483ae to c5e2597 Compare September 19, 2026 21:24
nx-cloud[bot]

This comment was marked as outdated.

@FrozenPandaz
FrozenPandaz force-pushed the feat/playwright-dev-server-locally branch from 566e8cb to 59bbfc6 Compare September 20, 2026 04:50
@FrozenPandaz
FrozenPandaz force-pushed the feat/playwright-dev-server-locally branch 2 times, most recently from 404a048 to 3b81979 Compare September 20, 2026 05:00
nx-cloud[bot]

This comment was marked as outdated.

@FrozenPandaz
FrozenPandaz force-pushed the feat/playwright-dev-server-locally branch from 7565530 to 3b81979 Compare September 21, 2026 05:28
@FrozenPandaz FrozenPandaz changed the title feat(testing): run generated e2e against the dev server locally and a production build in CI feat(testing): run generated playwright e2e against the dev server locally and a production build in CI Sep 21, 2026
@FrozenPandaz
FrozenPandaz marked this pull request as ready for review September 21, 2026 05:38
@FrozenPandaz
FrozenPandaz requested a review from a team as a code owner September 21, 2026 05:38
@leosvelperez
leosvelperez force-pushed the feat/playwright-dev-server-locally branch from 2aa137a to d261c79 Compare September 21, 2026 11:45
@leosvelperez
leosvelperez force-pushed the feat/playwright-dev-server-locally branch 2 times, most recently from dd80560 to a2694f5 Compare September 21, 2026 14:59
nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

Base automatically changed from fix/skip-nx-console-check-without-tty to master September 21, 2026 21:58
…b server

Add ciWebServerCommand and ciWebServerAddress. When they differ from the
local web server, the generated playwright.config.mts picks them when
`CI` is set, so a project can run e2e against the dev server locally and
a production build in CI. Without them the config is generated as before.
…pp generators

Application generators passed only one web server to Playwright, so
React, Vue, Web, Expo, Nuxt and Remix apps always ran e2e against
serve-static, even locally. Pass the dev server as the web server and the
production server as the CI web server, matching Cypress.
… in ci

When the CI and local addresses match, keep the url as a plain string instead of a ternary with identical branches.
Switching Angular apps to a production build in CI makes their e2e depend on the build passing its budgets, which the rspack module federation host does not. Keep Angular's previous behavior until that is fixed.
@FrozenPandaz
FrozenPandaz force-pushed the feat/playwright-dev-server-locally branch from 09e5038 to 1da22c4 Compare September 21, 2026 21:58

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a possible root cause for your failed CI:

We confirmed this failure is pre-existing: the same test fails with the identical expected/received values on master, unrelated to this PR's changes. Since the bug predates this PR, we're not fixing it here — it belongs in its own dedicated PR.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant