Playwright Bun: How to Run Playwright Tests on Bun in 2027 (Setup, CI, and Benchmarks)
Run Playwright tests on Bun with one flag, plus setup steps, a Windows fix, CI config, and real benchmark numbers.
Your website tests can now run on a faster engine, and switching takes one extra word in a command. Since November 2026, Playwright Bun support is official, so the tool that clicks through your site to check it works can run on Bun.
The problem is that most guides were written before that change. They mix up 2 different test runners, skip the Windows quirks, and leave you unsure whether your tests even run on Bun.
This guide uses a setup we ran on Playwright 1.65.1 and Bun 1.4.5, with real run screenshots, a Windows fix, CI config, and benchmarks. It goes deeper than our Playwright 1.65 release overview.
What is Playwright Bun and how does it work?
Playwright Bun means running Playwright tests with Bun as the package manager, the runtime, or both. Since Playwright 1.65, bunx --bun playwright test runs the test runner and its workers on Bun instead of Node.js.
People use the phrase for 3 different setups. Most of the confusion online comes from mixing them up, so it helps to name each one:
- Bun as the package manager: bun install replaces npm, but your tests still run on Node.js.
- Bun as the runtime for Playwright Test: the runner and every worker run on Bun. This is what Playwright 1.65 added.
- Bun's own test runner: bun test drives a browser through the Playwright library, without Playwright Test features.
The first mode only speeds up installs. The second changes the engine that loads and runs your test files, while the browser side of Playwright's architecture stays the same. The third swaps Playwright Test for a different runner.
Why the --bun flag decides everything
The flag exists because of a small line at the top of most command line tools. Playwright's CLI file starts with a Node shebang, and Bun's bunx docs say that by default, Bun respects shebangs and starts a node process for such files.
Passing --bun overrides that. The same docs say the flag must come before the executable name, because anything after the name is passed through to the tool itself.
We confirmed this by logging process.execPath from the Playwright config. Plain bunx playwright test reported node.exe, while bun --bun playwright test reported bun.exe.

The third branch is easy to miss. If you type bun test in a Playwright project, Bun's own runner starts instead of Playwright's, and it treats your spec files very differently.
A short history of Playwright and Bun
Support did not arrive overnight. Here is the timeline, based on primary sources:
- September 2023: Playwright maintainers closed the compatibility with Bun issue as not planned, because Bun was not yet Node.js compatible.
- August 20, 2026: the Bun 1.4 release notes said Playwright now runs on Bun, including playwright test with a config file and launching Chromium on Windows.
- November 5, 2026: Playwright 1.65 shipped with a "Run tests with Bun" section in its official release notes.
The Playwright team also states that its CI runs the test runner tests under Bun 1.4.3 on Linux. That detail matters later, when you pick a Bun version for CI.
Knowing which mode you want makes the setup simple, so the next step is building a project from scratch.
How to set up a Playwright Bun project in 5 steps
Here is the short version. Each step is explained below with the exact output we saw:
- Install Bun 1.4 or newer with the official installer for your OS.
- Scaffold the project with bun create playwright.
- Reinstall with Bun: delete package-lock.json, run bun install, and add @types/bun.
- Download browsers with bunx playwright install chromium.
- Run the tests on Bun with bunx --bun playwright test, or bun --bun playwright test on Windows.

Step 1: install Bun
Bun's installation docs list one command per platform:
curl -fsSL https://bun.com/install | bash
powershell -c "irm bun.sh/install.ps1|iex"
Run bun --version afterwards. Bun needs Windows 10 version 1809 or later, while Playwright's system requirements list Windows 11+, Windows Server 2019+, or WSL.
Step 2: what bun create playwright really does
We ran the official scaffolder in an empty folder:
bun create playwright --quiet --browser=chromium --gha
The log showed something most guides miss. Bun only fetched create-playwright, and the installer then ran npm init -y and npm install --save-dev @playwright/test.
The result was a normal npm project: a package-lock.json, a config file, a sample test, a GitHub workflow, and next steps that all start with npx. It installed Playwright 1.65.1, the latest patch at the time.
Step 3: switch the project to Bun
Remove the npm artifacts and let Bun install everything again:
rm -rf node_modules package-lock.json
bun install
bun add -d @types/bun
On our machine, bun install reported "5 packages installed [1.66s]" and wrote a text lockfile called bun.lock. The @types/bun package gives your editor types for globals like Bun.file.
Commit bun.lock and drop the npm lockfile. Keeping 2 lockfiles in one repo invites version drift between laptops and CI.
Steps 4 and 5: browsers, config, and the first run
Download a browser, then run the suite on Bun:
bunx playwright install chromium
bunx --bun playwright test
Without the flag, the install command runs on Node.js, which is fine because it only downloads browsers. On Linux CI, add --with-deps so the system libraries come along.
Our demo app is a small task list served by Bun.serve. Playwright starts it through webServer before the tests run:
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests',
fullyParallel: true,
retries: process.env.CI ? 2 : 0,
reporter: [['list'], ['html', { open: 'never' }]],
use: { baseURL: 'http://localhost:4173', trace: 'on-first-retry' },
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
webServer: {
command: 'bun app/server.ts',
url: 'http://localhost:4173/api/health',
reuseExistingServer: !process.env.CI,
},
});
Every option in this file worked the same on Bun in our runs, so a standard Playwright framework setup carries over without changes.
With the project installed, the next job is proving that your tests really run on Bun and not quietly on Node.
Running Playwright tests on Bun with the --bun flag
The official command is short, but there are 2 ways to type it, and they behave differently on Windows.
bunx --bun playwright test vs bun --bun playwright test
Here are both correct forms, plus the mistake people make most:
bunx --bun playwright test # the form in the Playwright 1.65 release notes
bun --bun playwright test # same idea through bun run, the one that worked on Windows
bunx playwright test --bun # wrong: Playwright receives the flag and rejects it
The first form is the one Playwright documents. The second goes through bun run, and it is the form that passed for us on Windows, for reasons covered in the errors section.
Check which runtime runs your tests
Never assume. This tiny test prints the runtime from inside a worker process:
import { test, expect } from '@playwright/test';
test('prints which runtime runs the tests', async ({}, testInfo) => {
const runtime = process.versions.bun
? `Bun ${process.versions.bun}`
: `Node.js ${process.version}`;
console.log(`Worker runtime: ${runtime}`);
testInfo.annotations.push({ type: 'runtime', description: runtime });
expect(runtime).toBeTruthy();
});
We ran our 13-test suite both ways. Without the flag, the worker reported Node.js v22.16.0 and our Bun-only test was skipped. With the flag, it reported Bun 1.4.5 and all 13 tests passed.

The annotation also appears in the Playwright HTML reporter, so anyone reading a report can tell which runtime produced it.
Use Bun APIs in tests without breaking Node runs
Once tests run on Bun, you can use Bun's built-in APIs, such as Bun.file for reading seed data. Guard them with test.skip so the same suite still runs on Node.js:
test('reads seed data with Bun.file', async () => {
test.skip(!process.versions.bun, 'Needs the Bun runtime (run with bunx --bun)');
const seed = await Bun.file('tests/fixtures/users.json').json();
expect(seed.users).toHaveLength(2);
});
Seed loaders like this fit naturally into Playwright fixtures, where one guarded helper can serve every test that needs data.
Make Bun the default with scripts or bunfig.toml
Typing the flag every time gets old. We tested 3 ways to bake it in, and all 3 ran the workers on Bun:
{
"scripts": {
"test": "playwright test",
"test:bun": "bun --bun playwright test",
"test:node": "playwright test"
}
}
- bun run test:bun uses the explicit script.
- bun --bun run test forces Bun for any script that would normally call Node.
- A bunfig.toml with bun = true in its run section makes plain bun run test use Bun.
[run]
bun = true
Per Bun's bunfig reference, this setting puts a node symlink that points to Bun at the front of PATH for every script started by bun run.
Tip: Keep a test:node script even after you switch. When a failure looks odd, rerunning it on Node.js tells you within seconds whether the bug is in your app or in the runtime.
If an AI coding agent writes or runs your tests, tell it about these scripts. The TestDino Playwright skill gives agents solid Playwright patterns, and one line about bun run test:bun in your project instructions stops them from defaulting to npx.
Running on Bun is not identical to running on Node, though, and a few differences can surprise you in reports and debugging.
What changes when Playwright runs on Bun
The Playwright 1.65 release notes list the behaviour that differs under Bun. Here it is side by side:
| Behaviour | Node.js | Bun (--bun) |
|---|---|---|
| TypeScript transpiling | Playwright uses Babel and its compilation cache | Bun transpiles test files itself |
| Watch mode and UI mode reruns on file change | Supported | Not available |
| --only-changed follows imports | ||
| --tsconfig and JSX options in tsconfig.json | Applied | No effect |
| Custom ESM loaders | Supported | Not supported |
| Async frames in stack traces | Included | Not included |
| API names in error messages | locator.click | click |
| Test console output in trace and UI mode | Captured | Not captured |
Most teams will never notice the TypeScript change. Two rows deserve a closer look, though: error text and console output in traces.
The same failure produces different error text
We wrote a test that clicks a button that does not exist and ran it on both runtimes:
import { test } from '@playwright/test';
test('clicks a button that does not exist', async ({ page }) => {
await page.goto('/');
await page.getByRole('button', { name: 'Archive' }).click({ timeout: 1000 });
});
Node.js reported TimeoutError: locator.click: Timeout 1000ms exceeded. Bun reported TimeoutError: click: Timeout 1000ms exceeded., and its stack frame read at (...) instead of a plain file path.

Interestingly, the step titles in our report were identical on both runtimes ("Click", "Fill", "Navigate"). The difference showed up only in error messages, which is exactly where dashboards group failures.
That has a practical side effect. If some jobs run on Node.js and others on Bun, one broken test can appear as 2 different errors in test failure analysis tools that cluster by message, so pick one runtime per pipeline.
Debugging gets a little harder
Console output from a test does not reach the trace or UI mode under Bun. If you read logs next to each action in the Playwright trace viewer, rerun the failing test with your test:node script.
The same goes for live reruns. Automatic reruns on file change in Playwright UI mode stop working once the runner moves to Bun.
Note: The Playwright team tests Playwright Bun mode on Bun 1.4.3 on Linux. Our Windows results come from one machine running Windows 10 and Bun 1.4.5, so treat them as a field report, not a support promise.
When to stay on Node.js
Bun mode works well for many suites, but stay on Node.js for now if any of these apply:
- You depend on watch mode, --tsconfig, tsconfig JSX options, or custom ESM loaders.
- Your debugging relies on console logs inside traces.
- Your tests import Node APIs that Bun has not fully implemented yet.
- Your reporting groups failures by error text across mixed runtimes.
Even when Bun fits, the first run rarely goes perfectly, so here are the errors we actually hit and how to fix each one.
Common Playwright Bun errors and how to fix them
Every error below came from our own runs on Playwright 1.65.1 and Bun 1.4.5. The exact text is included so you can match it against your terminal.
ReferenceError: Bun is not defined
This means your tests are running on Node.js while your code calls a Bun API. We triggered it by calling Bun.file in a test and running bunx playwright test without the flag:
ReferenceError: Bun is not defined
> 5 | const seed = await Bun.file('tests/fixtures/users.json').json();
Fix it by adding --bun before the command name, or guard the call with test.skip(!process.versions.bun) as shown earlier.
error: unknown option '--bun'
The flag landed after the command name, so Bun passed it straight to Playwright, which does not know it:
$ bunx playwright test --bun
error: unknown option '--bun'
Move the flag to the front, as in bunx --bun playwright test. This matches the rule in Bun's docs that flags after the executable name go to the executable.
Worker process exited unexpectedly on Windows
This was the biggest surprise of our testing. On Windows, bunx --bun playwright test failed all 13 tests before a single browser opened.

Each worker tried to install its own entry file as a package and gave up with InstallFailed cloning repository. Playwright then reported Error: worker process exited unexpectedly (code=1, signal=null) for every test.
We traced the cause by logging process.execPath inside the config for each command:
| Command | process.execPath | Result |
|---|---|---|
| bunx playwright test | node.exe | 12 passed, 1 skipped (Node.js) |
| bunx --bun playwright test | bunx.exe | 13 failed |
| bun --bun playwright test | bun.exe | 13 passed (Bun) |
Playwright starts each worker with child_process.fork(), which reuses process.execPath. In our install (Bun's official npm package), bunx.exe is a hard link to bun.exe that behaves like bun x, so every forked worker turned into a package install.
The fix is simple: on Windows, use bun --bun playwright test or a bun run script, which keep process.execPath on bun.exe. We did not test the PowerShell installer's layout, so check with the config log above if you installed Bun that way.
Playwright Test did not expect test() to be called here
Running plain bun test in a Playwright project starts Bun's runner. It picks up your *.spec.ts files and fails on each one:
error: Playwright Test did not expect test() to be called here.
Keep Bun runner tests in their own folder and point Bun at it:
[test]
root = "./bun-tests"
With that setting, bun test ran only our Bun runner file (1 pass) and left the Playwright specs alone. For anything not on this list, the usual Playwright debugging guide steps still apply, since the browser side does not change on Bun.
With the errors fixed, the remaining question is the one everyone asks first: is it actually faster?
Is Playwright faster on Bun? Real benchmark numbers
Speed is the main reason teams try Bun, so we looked at 2 kinds of numbers: Bun's official install benchmark and our own test run timings.
Install speed: Bun's official numbers
Installs are where Bun's speed claims are biggest. The benchmark on bun.com uses a T3-stack Next.js app with about 220 packages on Linux x64, reporting medians of 3 runs.

In that test, a first install took 1.41s with Bun versus 18.12s with npm. A CI install with a warm cache took 0.21s versus 4.45s.
Your own project will land somewhere different. Our small demo project, for example, reinstalled in 322ms with bun install --frozen-lockfile and a warm cache.
Installs are only one step of a CI job, though. Browser downloads and the test run itself are separate steps, so we measured the runner as well.
Test run speed: our Node vs Bun benchmark
We timed the same 13-test suite (8 UI tests, 3 API tests, 2 runtime checks) on both runtimes. Here is the setup:
- Machine: Windows 10 Pro (build 19045), Intel Core i5-10400F (6 cores, 12 threads), 8 GB RAM, SSD
- Versions: Playwright 1.65.1, Node.js 22.16.0, Bun 1.4.5, Chromium only
- Method: 4 workers, dot reporter, app server started once beforehand, 1 warm-up per command, then 20 timed runs per command in alternating order across 2 sessions
- Metric: median wall-clock time
| Scenario | Command | Runtime | Median (20 runs) |
|---|---|---|---|
| Full run | npx playwright test | Node.js | 3.56s |
| Full run | node node_modules/@playwright/test/cli.js test | Node.js | 2.44s |
| Full run | bun --bun playwright test | Bun | 1.94s |
| Discovery only | --list, fresh transform cache | Node.js | 0.88s |
| Discovery only | --list, warm transform cache | Node.js | 0.71s |
| Discovery only | --list | Bun | 0.48s |

What the numbers mean for your suite
On a full run, Bun finished in 1.94s against 2.44s for Node.js called directly, about 20% faster. Discovery alone was about 33% faster, which points to startup and file loading as the main source of the gain.
That also makes the saving mostly a fixed cost per run, around 0.5s here. On a long suite where browsers do most of the work, expect the percentage to shrink, while many short CI jobs or shards gain more in total.
The biggest single surprise was npx itself. On our Windows machine it added about 1.1s per run on top of Node.js, so calling a package script or the CLI directly is an easy saving on any runtime.
Tip: Before betting on a runtime switch for speed, model your CI first. The Sharding Calculator in TestDino's free tools estimates how many shards your suite needs to hit a time target.
Runtime is one lever among several. Workers, shards, and smarter test selection are the others that reduce Playwright CI runtime the most, and they stack with a Playwright Bun setup.
Speed only matters if the setup holds up in CI. Before getting there, one more choice needs clearing up: which runner to use at all.
bun test vs playwright test: which runner should you use?
Bun ships with its own test runner, which its docs describe as fast, built-in, and Jest-compatible. You can drive a browser from it with the Playwright library, and this file passed on our Windows machine in about 1.2s:
import { test, expect, beforeAll, afterAll } from 'bun:test';
import { chromium, type Browser } from '@playwright/test';
let browser: Browser;
const server = Bun.spawn([process.execPath, 'app/server.ts'], {
env: { ...process.env, PORT: '4174' },
stdout: 'ignore',
});
beforeAll(async () => {
await Bun.sleep(500);
browser = await chromium.launch();
});
afterAll(async () => {
await browser.close();
server.kill();
});
test('home page lists 3 tasks', async () => {
const page = await browser.newPage();
await page.goto('http://localhost:4174/');
await page.getByRole('listitem').first().waitFor();
expect(await page.getByRole('listitem').count()).toBe(3);
expect(await page.title()).toBe('Dino Tasks');
});
Notice what you have to build yourself: browser launch, server start, cleanup, and manual waiting. We also had to spawn the server with process.execPath, because spawning bun by name left an orphaned server holding the port on Windows.
What each runner gives you
Here is how the 2 options compare for browser testing:
| Feature | Playwright Test on Bun (--bun) | bun test + Playwright library |
|---|---|---|
| Config, browsers, and devices | playwright.config.ts with projects | None, you write setup code |
| Page, context, and request fixtures | Built in | Manual |
| Auto-retrying assertions | expect(locator).toBeVisible() and friends | Not available, use waitFor() |
| App server before tests | webServer option | Manual with Bun.spawn |
| HTML report and trace viewer | Built in | Not available |
| Sharding | --shard=1/4 | bun test --shard (Bun 1.4) |
| Best for | End-to-end suites | Quick browser checks next to unit tests |
For real end-to-end suites, Playwright Test on Bun keeps everything that makes Playwright worth using, such as Playwright assertions that wait on their own. Reach for bun test only when a quick browser check belongs next to your unit tests.
Both runners sit in the wider family of JavaScript testing frameworks, and the right pick depends on how much of Playwright's tooling you need.
Where Bun.WebView fits
Bun 1.4 also added Bun.WebView, which the Bun 1.4 release notes describe as headless browser automation built into Bun, without Puppeteer or Playwright. On macOS it uses the system WebKit, and it can drive an installed Chrome, Chromium, or Edge.
It is handy for screenshots and simple scripts. It is not a replacement for Playwright in testing: there is no test runner, the notes list no Firefox support, and none of the reporting above comes with it.
Once you have picked Playwright Test on Bun, the last step is running it in CI the same way every time.
Running Playwright on Bun in GitHub Actions
The workflow that bun create playwright generated used npm ci and npx, so it needs a few changes before it runs on Bun.
A Playwright Bun GitHub Actions workflow
Here is a Bun version built on the official setup-bun action:
name: Playwright on Bun
on:
push:
branches: [main]
pull_request:
jobs:
test:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.3
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Install Playwright browsers
run: bunx playwright install --with-deps chromium
- name: Run Playwright tests on Bun
run: bunx --bun playwright test
- uses: actions/upload-artifact@v7
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 14
Three details in this file matter:
- Pinned Bun version: 1.4.3 matches the version Playwright's own CI uses for this mode, so upgrades happen on purpose.
- Frozen lockfile: the job fails if bun.lock is out of date, instead of quietly installing different versions.
- Browsers on Node.js: bunx playwright install runs on Node.js, which GitHub's Ubuntu images include.
We ran these same commands locally rather than on GitHub's runners. For caching, artifacts, and secrets, the rules for running Playwright in GitHub Actions on Node apply unchanged.
Split the suite with shards
Playwright's --shard flag works under Bun too. In our test, --shard=1/2 ran 7 tests and --shard=2/2 ran the other 6, all on Bun. A matrix job spreads the shards across machines:
strategy:
fail-fast: false
matrix:
shard: [1/4, 2/4, 3/4, 4/4]
steps:
- run: bunx --bun playwright test --shard=${{ matrix.shard }}
Picking the right shard count and merging the results back together works exactly as it does in standard Playwright sharding.
Keep a Node.js job as a safety net
Note: Bun mode still has documented gaps, such as no watch mode and no console output in traces. A scheduled Node.js job gives you a baseline, so a failure that happens only on Bun points straight at the runtime.
Reporting ties it together. When both jobs upload results to one place, Playwright test reporting shows Node and Bun runs side by side, and flaky test detection separates runtime issues from random flakes.
A tool like TestDino keeps that history across branches and runs, which is what you need when you are deciding whether a runtime switch actually helped.
Conclusion
Playwright Bun support has gone from a closed GitHub issue to an official, documented mode in about 3 years. For most suites, the switch is one flag, a fresh bun.lock, and a pinned Bun version in CI.
Our numbers showed a real but modest gain on the runner, about 20% on a small suite, and a much larger gain on installs, per Bun's own benchmark. The trade-offs sit in debugging: different error text, no console output in traces, and no watch mode.
Start with one CI job, keep a Node.js script for debugging, and use bun --bun playwright test on Windows. Every one of the usual Playwright best practices still applies, because the browser side does not change at all.
FAQs

Ayush Mania
Forward Development Engineer