Skip to content

Fix flaky playground e2e tests#11159

Draft
timotheeguerin wants to merge 3 commits into
mainfrom
fix-playground-e2e-flaky
Draft

Fix flaky playground e2e tests#11159
timotheeguerin wants to merge 3 commits into
mainfrom
fix-playground-e2e-flaky

Conversation

@timotheeguerin

@timotheeguerin timotheeguerin commented Jul 2, 2026

Copy link
Copy Markdown
Member

Problem

The @typespec/playground-website e2e tests are flaky in CI — the first one or two tests (compiled http sample, report compilation errors) intermittently fail at page.goto (ui.e2e.ts:24), while the later tests pass.

This is not a timeoutpage.goto completes in ~1–2.5s locally. The root cause is the Playwright webServer using the Vite dev server (pnpm watch). The dev server transforms modules on demand and re-optimizes dependencies on the first page load; when it discovers a new dependency mid-load it issues a full page reload that aborts the in-flight navigation (net::ERR_ABORTED). That fails fast and only affects whichever test runs first — subsequent tests hit an already-optimized server and pass.

Change

  • Serve the pre-built app with vite preview instead of the dev server. The test:e2e turbo task already dependsOn: ["build"], so dist/web is always available. There is no on-demand transform, dependency re-optimization, or HMR reload, so the first navigation is deterministic (full suite: ~6s vs ~2m before).
    • Set cwd to the package root so vite preview resolves vite.config.ts (build.outDir = dist/web).
  • Keep a single CI retry as a safety net.

Validation

  • CI=1 pnpm test:e2e — 4/4 tests pass consistently in ~6s (previously ~2.1m with intermittent first-test failures).
  • pnpm lint passes.

Note

The dev-server dependency re-optimization reload is timing-dependent, so it does not reproduce on every cold local run; CI's slower/different timing is what surfaces it. Serving the static build removes the mechanism entirely regardless of timing.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

The Playwright webServer used the Vite dev server (`pnpm watch`). The dev server transforms modules on demand and re-optimizes dependencies on the first page load; when it discovers a new dependency mid-load it issues a full page reload that aborts the in-flight `page.goto` (net::ERR_ABORTED). This is fast (not a timeout) and only hits whichever test runs first, so the first test(s) flaked while later ones passed.

Serve the pre-built app with `vite preview` instead (the `test:e2e` turbo task already depends on `build`), so there is no on-demand transform, dependency re-optimization, or HMR reload. Set `cwd` to the package root so preview resolves `vite.config.ts` (outDir dist/web). Keep a single CI retry as a safety net.
@timotheeguerin timotheeguerin force-pushed the fix-playground-e2e-flaky branch from 172c83c to a079033 Compare July 2, 2026 20:56
@azure-sdk-automation

azure-sdk-automation Bot commented Jul 2, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant