Skip to content

chore: install the Playwright browsers before the browser tests - #327

Merged
kurkle merged 1 commit into
mainfrom
chore/install-test-browsers
Nov 19, 2026
Merged

kurkle merged 1 commit into
mainfrom
chore/install-test-browsers

Conversation

@kurkle

@kurkle kurkle commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Problem

Every Playwright release pins its own browser builds. After any Playwright bump, npm test fails locally with browserType.launch: Executable doesn't exist until npx playwright install has been run by hand. The pre-commit hook runs npm test, and the prepare script enables the hook, so a fresh clone cannot commit.

Change

package.json gets four pre scripts, one for every script that runs a Vitest browser-mode config, each installing exactly the browsers that script uses:

  • pretest:fixture and predev: playwright install chromium firefox (vitest.browser.config.ts)
  • pretest:integration:min-bundle: playwright install chromium (vitest.integration.config.ts)
  • prefixtures:update: playwright install chromium (fixtures:update runs the fixture suite in its chromium-only mode)

When the right builds are present the command only checks and exits (about 0.5 s); otherwise it downloads them. It is not tied to postinstall/prepare: CI installs with --ignore-scripts and installs its browsers explicitly, and an install hook would download browsers for people who never run the tests. The hook, workflows and Vitest configs are unchanged. chore: so no release is triggered.

Verification

With PLAYWRIGHT_BROWSERS_PATH pointing at an empty directory: npm run test:fixture on main fails with Executable doesn't exist; with this change it downloads chromium and firefox and passes (96 tests), and npm run test:integration:min-bundle then passes (5 tests). Build, lint, typecheck, npm test and the pre-commit hook pass.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 12.7 kB

ℹ️ View Unchanged
Filename Size
dist/chartjs-plugin-gradient.cjs 3.63 kB
dist/chartjs-plugin-gradient.esm.js 3.47 kB
dist/chartjs-plugin-gradient.js 3.63 kB
dist/chartjs-plugin-gradient.min.js 2.02 kB

compressed-size-action

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Deploying chartjs-plugin-gradient with  Cloudflare Pages  Cloudflare Pages

Latest commit: 683b980
Status: ✅  Deploy successful!
Preview URL: https://7a5a0713.chartjs-plugin-gradient.pages.dev
Branch Preview URL: https://chore-install-test-browsers.chartjs-plugin-gradient.pages.dev

View logs

Every Playwright release pins its own browser builds, so after any
Playwright bump `npm test` fails with "browserType.launch: Executable
doesn't exist" until `npx playwright install` has been run by hand. The
pre-commit hook runs `npm test`, and the `prepare` script enables the
hook, so a fresh clone could not commit either.

Every npm script that runs a Vitest browser-mode config now has a `pre`
script that runs `playwright install` for exactly the browsers that
script uses: chromium and firefox for `test:fixture` and `dev`
(vitest.browser.config.ts), chromium for `test:integration:min-bundle`
(vitest.integration.config.ts), and chromium for `fixtures:update`, which
runs the fixture suite in its chromium-only mode. When the right builds
are present the command only checks and exits (about 0.5 s); otherwise it
downloads them.

The install is not tied to `postinstall` or `prepare`: CI installs with
`--ignore-scripts` and installs its browsers explicitly, and a lifecycle
install hook would download browsers for people who never run the tests.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@kurkle
kurkle force-pushed the chore/install-test-browsers branch from 82d96e4 to 683b980 Compare November 19, 2026 16:45
@sonarqubecloud

Copy link
Copy Markdown

@kurkle
kurkle merged commit 2925992 into main Nov 19, 2026
6 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.

1 participant