Run tests in CI
A GitHub Actions job that runs the Node and browser tests, and every fixture, matcher and mock of @webmcp-agents/testing in one table.
The Node tests need nothing but Node. The browser tests need Playwright’s Chromium, installed once per job.
A complete example
# .github/workflows/test.yml
name: test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with: { node-version: 24, cache: pnpm }
- run: pnpm install --frozen-lockfile
# Browser-mode tests run in Playwright's Chromium.
- run: pnpm exec playwright install --with-deps chromium
- run: pnpm exec vitest run
No test reaches a model or the network: mockAdapter and mockModel stand in for the model, so the job needs no
secret. End-to-end tests need the app running; add Playwright’s webServer and a playwright test step for them.
If a test fails only in CI
- “left a tool call running”: a call was started and never awaited. Await it, or abort it.
- “left a tool registered”: a tool registered with
registerWebToolortools.mockoutside a component was not unregistered. Mocks are removed for you; your own registrations are yours. - Timing: wait with
expect.polloruntil, never a fixed sleep. Motion is already reduced.
Every fixture, matcher and mock
| API | What it is |
|---|---|
callTool |
Call a tool the way an agent would and get the result it would read. |
events |
Every AgentEvent from the start of the test, with helpers. |
| Page helpers | fixture, until, recordEvents, uniqueName, toolForm and the other small helpers. |
mockAdapter |
A model-free AgentAdapter that plays a script and remembers what it did. |
mockChatServer |
An in-memory /api/chat for the real cloud adapter. |
mockModel |
A scripted AI SDK model for createChatHandler: no provider key, no network. |
mockTool |
Register a page tool backed by a vi.fn spy. |
mount |
Mount HTML or a React element into the page; removed after the test. |
| openApp, runTool, listTools, parkedOn, confirm | Drive a page’s WebMCP tools from Playwright, the way an agent would. |
redactor |
A fresh page redactor per test, reset after it. |
renderChat |
Render AgentChat for a test, open, with a mock adapter; with the sentinel catalog, every string the chat owns is a marker. |
runs |
Every AgentRunEvent of the test, for the run matchers and privacy checks. |
| chatRequest, readChatStream, withSession | Build /api/chat requests, read the streamed answer, carry a session. |
@webmcp-agents/testing/setup |
The browser setup file: polyfill, reduced motion, deterministic ids, cleanup and leak checks. |
spans |
Every browser span of the test, kept in memory, with flush() for the buffered ones. |
| memoryExporter, spanTree | An in-memory span exporter for both sides of a trace, and spans as trees. |
test |
Vitest’s test, extended with the kit’s fixtures. |
toBeOneTrace |
Every span belongs to one trace, with one root. |
toBeToolError |
The tool result failed, with the expected error code when one is given. |
toBeToolResult |
The tool result succeeded, and its text matches when an expected text is given. |
toContainSensitive |
One of the given values is somewhere in this sink; used negated to prove a secret leaks nowhere. |
toHaveAnswered |
The run’s answer contains or matches the expected text. |
toHaveBeenOfferedTools |
Every model step of the mock adapter was offered these tools. |
toHaveCalledTool |
The run called the tool, with an input containing the given keys when given. |
toHaveCalledTools |
The run called exactly these tools, in this order. |
toHaveEventOrder |
These event types happened in this order, others allowed between them. |
toHaveFilled |
The agent’s value went into a field, with the expected value when one is given. |
toHaveFinishedWith |
The run ended this way, with this error code when given. |
toHaveNoHardcodedText |
The rendered chat shows no text that bypassed its messages catalog: only sentinel markers, punctuation, digits and the text you allow. |
toHaveParked |
A tool waited for the person, with the expected prompt when one is given. |
toHaveSpan |
The spans include one with this name (or matching it) and these attributes. |
toHaveStarted |
A tool run started, for the named tool when one is given. |
toHaveStructuredContent |
The tool result’s structuredContent has these keys with these values. |
toHaveYielded |
The cursor got out of the person’s way, for the given reason when one is given. |
tools |
The page’s tools as an agent reaches them: call, list, mock, settled. |
user |
Trusted input in a browser-mode test: confirm, moveOn, scroll, click, type. |
webAgentsProject |
The two Vitest projects a WebMCP app needs, so a config is two lines. |