Skip to content

Cache Playwright browsers in CI (#33) - #37

Merged
goodeats merged 6 commits into
devfrom
cursor/playwright-ci-cache-ba9d
Aug 25, 2026
Merged

Cache Playwright browsers in CI (#33)#37
goodeats merged 6 commits into
devfrom
cursor/playwright-ci-cache-ba9d

Conversation

@goodeats

@goodeats goodeats commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Closes #33

Caches Playwright Chromium so the e2e job can get past Install Playwright Browsers instead of hanging until the 60-minute job timeout.

What changed

  • Cache ~/.cache/ms-playwright by OS + @playwright/test version
  • Cache miss: install with 15-minute step timeout; cache hit: install-deps chromium
  • Playwright stays required for deploy

Collection (Playwright 1.51 on Node 22.18)

  1. Vite sprite.svg is not JS — stub with tests/svg-import-stub.cjs, env set before Playwright starts (PW_TEST_SOURCE_TRANSFORM)
  2. Node 22.18+ type-stripping rejects parameter properties — NODE_OPTIONS=--no-experimental-strip-types so Playwright’s own TS transform runs

Not bumping @playwright/test (#29). Epic Stack avoids this via Playwright 1.58.

Test Plan

  • Install Browsers finishes well under 60 minutes
  • Collection succeeds; e2e tests run
  • After merge to dev, staging deploy can proceed
Open in Web Open in Cursor 

Cache ~/.cache/ms-playwright by OS and @playwright/test version so
browser install is skipped on hit, with a 15-minute timeout on miss.
On cache hit, still install Chromium OS deps.

Also stub Vite .svg imports during Playwright collection so CI can get
past Unknown file extension errors that blocked the #31 merge deploy.

Co-authored-by: Pat Needham <p@patn.dev>
cursoragent and others added 5 commits August 25, 2026 17:49
Drop build.external, the Babel SVG transform, and the ESM loader.
Those extras caused GHA collection to fail with Unknown file extension
.svg; Epic Stack does not stub this and their config does not
externalize SVG. Keep the versioned Playwright browser cache.

Co-authored-by: Pat Needham <p@patn.dev>
Matching Epic Stack’s playwright.config on Playwright 1.51 made GHA
parse sprite.svg as JS (SyntaxError). Keep the #24 Babel rewrite so
collection never loads the SVG file, but do not mark **/*.svg as
external (that caused Unknown file extension .svg). Cache unchanged.

Co-authored-by: Pat Needham <p@patn.dev>
PW_TEST_SOURCE_TRANSFORM set inside playwright.config.ts never reached
the loader thread on GHA, so collection still parsed sprite.svg as JS.
Pass the plugin via '@playwright/test'.babelPlugins (copied over the
loader channel) and set the env vars on the workflow test step before
Playwright starts. Cache unchanged.

Co-authored-by: Pat Needham <p@patn.dev>
GHA already injects PW_TEST_SOURCE_TRANSFORM before Playwright starts.
Also passing it as babelPlugins made Babel error: Duplicate plugin/preset.
Keep the workflow env; config only sets the vars if they are unset.

Co-authored-by: Pat Needham <p@patn.dev>
SVG collection is past the sprite SyntaxError. Node 22.18+ then fails
on constructor parameter properties (tests/pom/base/page.pom.ts) in
strip-only mode. Set NODE_OPTIONS=--no-experimental-strip-types on the
test step so Playwright's Babel transform runs instead.

Co-authored-by: Pat Needham <p@patn.dev>
@goodeats
goodeats merged commit f78331b into dev Aug 25, 2026
7 checks passed
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.

2 participants