Donobu Playwright Enhancements and Fixtures
How Donobu enhances Playwright's page fixture and adds two custom fixtures for AI provider override and pre-authenticated browser state.
Donobu enhances Playwright's built-in page fixture with AI-driven capabilities, and adds two custom fixtures of its own. Importing test from donobu gives every test the enhanced page object plus access to the additional fixtures.
import { expect, test } from 'donobu';
All of Playwright's standard exports (expect, devices, etc.) are re-exported from donobu, so you do not need to import from both packages.
Just as with Playwright itself, you can define your own additional fixtures on top of Donobu's. See Playwright's fixtures documentation for details.
What Donobu adds
The Donobu test object has the same default fixtures as Playwright, with one enhanced and two new ones added:
| Fixture | Type | Description |
|---|---|---|
page | DonobuExtendedPage | Enhanced — adds ai, find, changeTab, and runAccessibilityTest to the standard Playwright page |
gptClient | GptClient | New — the resolved AI client for this test. Override with test.use({ gptClient: ... }) |
storageState | BrowserStorageState | New — pre-authenticated browser state to inject at test start |
Overriding the AI provider per test file
Use test.use() to swap the AI provider for an entire test file or describe block:
import { anthropicClientFixture, test } from 'donobu';
// All tests in this file use the Anthropic client
test.use({ gptClient: anthropicClientFixture('claude-sonnet-4-6') });
test('my test', async ({ page }) => {
await page.ai('Complete the onboarding flow');
});
Available fixture factory functions:
| Factory | Provider |
|---|---|
donobuGptClientFixture(apiKey?) | Donobu hosted |
anthropicClientFixture(modelName, apiKey?) | Anthropic |
googleGeminiClientFixture(modelName, apiKey?) | Google Gemini |
openAiClientFixture(modelName, apiKey?) | OpenAI |
Pre-authenticated browser state
Use storageState to inject cookies and local storage from a previous session, so tests start already logged in without the AI spending tokens on authentication:
import { test } from 'donobu';
// Path to a saved browser state file (cookies + localStorage)
test.use({ storageState: 'playwright/.auth/user.json' });
test('dashboard loads correctly', async ({ page }) => {
await page.goto('https://app.example.com/dashboard');
await page.ai.assert('The dashboard is fully loaded with the user\'s name visible');
});
To generate the state file, run a one-time setup fixture — see Playwright's authentication guide for details.
What is attached to the test report
Donobu attaches the following to the Playwright test report. stdout and stderr are standard Playwright attachments; the rest are added by Donobu.
| Attachment | Format | When | Description |
|---|---|---|---|
stdout | text | Always | Standard output captured during the test (Playwright built-in) |
stderr | text | Always | Standard error captured during the test (Playwright built-in) |
test-flow-metadata.json | JSON | Always | Full flow metadata: run mode, tool call count, token usage, start/end times, and final state (SUCCESS / FAILED) |
donobu-step-{n}-{toolName} | image | Always | Screenshot captured after each tool call, keyed by step index and tool name |
donobu-step-summary | JSON | Always | Summary of all tool calls: tool name, page URL, timestamps, success/failure, and a short description of each step's outcome |
donobu-triage-evidence | JSON | On failure | Structured failure evidence including a screenshot, page DOM snapshot, and AI-generated triage analysis classifying the likely root cause |
These attachments are visible in the Playwright HTML report and in Donobu Studio.