Skip to main content
This guide shows you how to test WebMCP tools against both the native Chromium implementation and the polyfill runtime, and when to use each testing lane.

Understand the testing lanes

The monorepo provides several testing lanes organized by runtime: Every canonical E2E suite proves the same six assertions against the real runtime:
  1. Initial discovery returns the expected tools
  2. A successful call returns the expected payload
  3. The runtime records the invocation
  4. Dynamic registration becomes discoverable without restart
  5. Unregistration removes the tool and later calls fail
  6. Runtime-thrown tool errors propagate to the caller

Run the canonical polyfill tests

The polyfill tests use Playwright with a real browser. They exercise @mcp-b/global running in a page, discovered and called through the SDK Client and TabClientTransport.
These tests use the shared fixture in e2e/runtime-contract/ which registers a deterministic tool set: echo, sum, dynamic_tool, and always_fail.

Run the native Chromium tests

Native Chromium tests use the browser’s built-in document.modelContext and navigator.modelContextTesting APIs directly. This is the one exception to the SDK-client pattern: the browser API itself is the public boundary.

Default Chromium

Chrome 152+ with WebMCP flags

1

Install Chrome 152 or newer

Use Chrome Canary, Dev, Beta, or Stable at major version 152 or newer. If Playwright cannot find it automatically, set CHROME_BIN to the executable path.
2

Run the flagged native contract lane

This uses the Playwright config that passes:
  • --enable-experimental-web-platform-features
  • --enable-features=WebMCPTesting,DevToolsWebMCPSupport

Detect native vs. polyfill in your own code

If you need runtime detection (for conditional test paths or feature flags):

Configure Playwright for native testing

To launch Chromium with the native API enabled in your own Playwright tests:
For headless CI environments, add --headless=new, --disable-gpu, and --no-sandbox:
--no-sandbox disables critical security features. Use it only in trusted CI environments.

Run integration and framework tests

Beyond the canonical contract lanes, the monorepo has additional integration suites:
These lanes are useful for broader compatibility checks but are not the canonical E2E gate.

Debug failing tests

Troubleshoot common issues

Choose the right testing approach