npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vitest-browser-bun

v0.0.4

Published

Vitest Browser Mode provider powered by Bun.WebView, with verified process-isolated parallel sessions via isolated factories.

Readme

vitest-browser-bun

A Vitest Browser Mode provider powered directly by Bun.WebView using the Chrome backend.

It runs Vitest browser tests in Chromium without Playwright, WebDriverIO, Puppeteer, or another browser-driver runtime dependency. The published package has zero regular runtime dependencies; vitest and @vitest/browser are peer dependencies.

0.0.4 targets Vitest 5.0.x and keeps a narrow peer range because Vitest's custom browser-provider API is experimental.

Why use it?

Vitest Browser Mode
        │
        ▼
 vitest-browser-bun
        │
        ├── Bun.WebView native browser operations
        └── Bun.WebView.cdp()
                 │
                 ▼
              Chromium

Vitest remains responsible for test discovery, Vite module serving, mocking, Browser UI, assertions, trace view, coverage integration, and locator semantics. This package implements the provider bridge from those APIs to Bun.WebView and Chrome DevTools Protocol.

Requirements

  • Bun: >=1.3.12
  • Vitest: >=5.0.0 <5.1.0
  • @vitest/browser: matching 5.0.x
  • Browser: a Chromium-family executable discoverable by Bun, or an explicit chromePath
  • Runtime: the Vitest CLI must run under Bun

The provider accepts the Vitest browser names chromium and chrome. Both use the same Bun.WebView Chrome backend. Use chrome for Vitest V8 browser coverage because Vitest 5.0.1 validates that mode against the chrome browser name.

Install

bun add -D [email protected] @vitest/[email protected] vitest-browser-bun

Configure Vitest

import { defineConfig } from 'vitest/config'
import { bunWebView } from 'vitest-browser-bun'

export default defineConfig({
  test: {
    browser: {
      enabled: true,
      headless: true,
      provider: bunWebView(),
      instances: [{ browser: 'chromium' }],
    },
  },
})

Run Vitest under Bun:

bun run --bun vitest run

A package script is convenient:

{
  "scripts": {
    "test:browser": "bun run --bun vitest run"
  }
}

bun run vitest can respect Vitest's #!/usr/bin/env node shebang and start the CLI under Node. A Node process cannot construct Bun.WebView, so use bun run --bun. Do not substitute bun test; that invokes Bun's own test runner rather than Vitest.

Provider options

bunWebView({
  // Optional Chromium-family executable. Bun auto-detects when omitted.
  chromePath: '/path/to/chrome',

  // Extra flags appended to Bun's Chrome launch arguments.
  chromeArgs: ['--lang=en-US'],

  // Initial viewport overrides. Otherwise Vitest browser.viewport is used.
  width: 1280,
  height: 720,

  // Normally leave false because Vitest already handles test console output.
  forwardConsole: false,

  // Useful when diagnosing browser startup failures.
  stdout: 'ignore',
  stderr: 'ignore',

  // Optional construction/isolation boundary. The built-in direct factory is
  // serialized; a factory may enable file parallelism only by explicitly
  // declaring isolatedSessions === true and satisfying the isolation contract.
  webViewFactory: undefined,
})

The provider uses Bun's Chrome backend with url: false, so it starts its own browser instead of attaching to an unrelated remote-debugging instance.

Supported surface

The 0.0.4 conformance and regression suites cover:

  • Vitest semantic locators and locator composition
  • expect.element(...)
  • custom locator extensions
  • click, double-click, triple-click, buttons, modifiers and positions
  • fill, clear, type, keyboard state, tab and cleanup
  • hover, unhover and wheel
  • selectOptions
  • native HTML5 drag/drop and pointer-style drag fallback
  • clipboard copy, cut and paste
  • uploads from browser File objects and project-relative files
  • same-origin frameLocator, including nested same-origin frames
  • open Shadow DOM locators and native interactions
  • actionability, scrolling, force and obscuring overlays
  • page and locator screenshots
  • screenshot assertions and failure screenshots
  • viewport changes
  • public cdp() send/event APIs
  • browser mocking
  • custom Browser Commands
  • multiple Chromium instances
  • Browser UI mode
  • orchestrator scripts
  • Vitest Trace View
  • V8 and Istanbul browser coverage

The default direct Bun.WebView factory advertises supportsParallelism = false because Chrome-backed WebViews created in one Bun process share browser state. vitest-browser-bun supports Vitest browser-file parallelism when an injected factory explicitly guarantees isolated sessions. The reference implementation is [email protected], which uses one Bun helper/Chrome isolation boundary per active lease.

Supported process-isolated parallelism

Install the standalone isolation package alongside the provider:

bun add -D [email protected]

Then inject its factory:

import { defineConfig } from 'vitest/config'
import { createParallelWebViewFactory } from 'bun-webview-parallel'
import { bunWebView } from 'vitest-browser-bun'

export default defineConfig({
  test: {
    browser: {
      enabled: true,
      headless: true,
      provider: bunWebView({
        webViewFactory: createParallelWebViewFactory({ pool: true }),
      }),
      instances: [{ browser: 'chromium' }],
    },
    fileParallelism: true,
    maxWorkers: 4,
  },
})

The default provider path remains direct and serialized. vitest-browser-bun enables supportsParallelism only when the injected factory declares isolatedSessions === true; labels such as isolation: 'process' do not enable parallel scheduling by themselves. The provider does not import subprocess or IPC code itself.

bun-webview-parallel uses attached Bun helper processes as the isolation boundary. By default each created WebView owns a dedicated helper. [email protected] can optionally reuse released helpers with createParallelWebViewFactory({ pool: true }); context reset and pool lifecycle stay inside that package, so no locator/action/provider logic changes.

The supported claim is deliberately scoped: it covers the process-isolated configuration and the browser/session surfaces listed in the conformance capability manifest. It is not a claim that every possible Chromium or operating-system state surface is equivalent to a Playwright browser context. Custom factories may opt in with isolatedSessions: true, but they are responsible for meeting the same isolation contract.

See docs/PARALLELISM.md for the integration architecture.

The release conformance matrix includes synchronized four-session state/permission isolation, routing/CDP isolation, crash containment, sustained pooled-host churn, and a 16-file Vitest orchestration/artifact matrix. bun run test:capabilities audits the machine-readable proof map in docs/parallel-capabilities.json; run bun run test:parallel for the normal gate or bun run test:parallel:soak for repeated stress.

The orchestration matrix runs 16 real browser files with four workers against a pooled process-isolated factory. Every overlap sample must contain four distinct Vitest sessions and helper PIDs, while each file concurrently exercises a custom BrowserCommand, native interaction, CDP evaluation, trace-view marks, and a uniquely saved screenshot. A separate expected-failure matrix verifies that parallel screenshotFailures output produces distinct failure artifacts instead of colliding on shared paths.

Raw CDP

The provider augments Vitest's CDPSession and maps the public cdp() facade to the active Bun.WebView:

import { cdp } from 'vitest/browser'

const result = await cdp().send('Runtime.evaluate', {
  expression: 'document.title',
  returnByValue: true,
})

Supported session methods:

  • send
  • on
  • off
  • once

Provider commands and public CDP calls share a per-session operation queue so Bun.WebView operations do not race each other.

Custom Browser Commands

Vitest Browser Commands receive the standard command context plus Bun-specific handles:

import type { BrowserCommand } from 'vitest/node'

export const getTitle: BrowserCommand<[]> = async ({ bunWebView }) => {
  return bunWebView.evaluate<string>('document.title')
}

The context exposes:

  • webview — the real Bun.WebView in direct mode, or the injected WebView proxy in isolated mode
  • bunWebView — the provider session wrapper, which serializes operations

Prefer bunWebView when command ordering matters.

Compatibility notes

  • Chromium engine only. chromium and chrome both select the Bun.WebView Chrome backend.
  • Headless only for the current 0.0.x line.
  • Vitest must run under Bun.
  • Browser-file parallelism is supported with a verified isolated factory. [email protected] is the reference process-isolated implementation. The built-in direct Bun.WebView factory remains serialized.
  • No Playwright .trace.zip. Vitest's provider-independent Trace View is supported; Playwright trace archives are provider-specific.
  • Same-origin frame traversal is verified. Cross-origin frame behavior is not claimed.
  • Open Shadow DOM is verified. Closed roots are not traversable through ordinary page JavaScript.
  • V8 coverage uses the chrome alias in Vitest 5.0.1.

See docs/COMPATIBILITY.md for the detailed provider comparison.

Testing the provider itself

For contributors and maintainers:

bun run test:browser
bun run test:regression
bun run test:conformance

test:regression is the focused bug-regression runner. test:conformance is the full release gate.

See:

Maintenance policy

When Vitest, Vite, Bun or Chromium changes:

  1. keep the existing compatibility range until the candidate is tested;
  2. reproduce any failure with the narrowest conformance group;
  3. add or strengthen a regression when the provider is wrong;
  4. make the smallest provider change needed;
  5. run the focused regression runner;
  6. run the complete conformance matrix;
  7. only then widen compatibility or publish.

License

MIT