Contents

Playwright v1.65.0 officially supports running its test runner on Bun. You can now run tests with Bun, but differences in watch behavior and TypeScript configuration mean you should validate the migration before changing CI.

Key Points#

  • Playwright v1.65.0 officially supports Bun as a runtime for its test runner.
  • Bun transpiles TypeScript test files itself, so Playwright does not use Babel or its compilation cache.
  • Watch Mode is unavailable, and UI Mode does not automatically rerun tests after file changes.
  • The --only-changed option has limitations, and --tsconfig has no effect on Bun.

What Bun Support Changes#

This change concerns the runtime that runs Playwright’s test runner. Node.js remains available, with Bun joining it as an officially supported option.

For TypeScript tests, the execution process changes. The Playwright release notes state:

> The test runner now works on Bun. Bun transpiles TypeScript test files itself, so Playwright uses neither Babel nor its compilation cache.

This gives teams using Bun official support for running Playwright tests in that environment. It does not mean every feature available with the Node.js runner is supported. Evaluate runtime support and workflow compatibility separately.

Why TypeScript Handling Matters#

When Playwright runs on Bun, Bun converts TypeScript test files into executable JavaScript. Playwright therefore does not use Babel transformations or its compilation cache.

These steps are removed from the execution path, but that does not establish that every test suite will run faster. The provided release information contains no benchmark figures. Browser startup, application response times, and the tests themselves all affect total execution time.

Transpilation also does not replace TypeScript type checking. If your project runs type checks separately, continue doing so while evaluating Bun. Passing tests show that those tests ran successfully. They do not show that the entire project passes type checking.

How to Evaluate the Switch#

Start with a small, repeatable comparison. Use Playwright v1.65.0, record the Bun version you are evaluating, and keep the application build and browser versions consistent across runs.

1. Run a representative set of tests in your existing Node.js environment and save the results. 2. Run the same tests with Playwright’s test runner on Bun, using the launch method documented for v1.65.0. 3. Compare test discovery, pass/fail results, and the behavior of any setup and teardown used by the test suite. 4. Run the entire test suite on Bun before changing shared CI settings.

During the comparison, verify which runtime the runner actually uses. Installing dependencies with Bun alone does not necessarily mean the Playwright runner is running on Bun. If speed informs your decision, measure multiple runs under equivalent conditions and record whether dependency and browser installation times are included.

Workflow Differences#

There are four limitations to consider before adoption.

  • Watch Mode: Unavailable on Bun, affecting workflows that rely on continuous test execution.
  • UI Mode: Tests do not automatically rerun when files change, altering the interactive development cycle.
  • `--only-changed`: Has limitations. Before using it to select tests, check the v1.65.0 documentation to confirm it suits your use case.
  • `--tsconfig`: Has no effect on Bun, so do not assume the configuration selected with this flag will apply.

The --tsconfig difference is especially important if your test command explicitly selects a TypeScript configuration. Do not assume existing commands retain the same meaning; verify the behavior your tests need, including imports that depend on that configuration.

Teams that primarily run their full test suite in CI may find these limitations easier to accommodate. Teams that rely on automatic reruns during development have more to check. Choose a runtime that fits your actual workflow, and retain your existing Node.js commands until Bun passes your comparison checks.

Next Steps#

Run a representative set of tests on Bun using Playwright v1.65.0 and compare the results with the same tests on Node.js before changing your default test command.

Source: https://www.publickey1.jp/blog/26/playwrightbun.html

Contents