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:

FixtureTypeDescription
pageDonobuExtendedPageEnhanced — adds ai, find, changeTab, and runAccessibilityTest to the standard Playwright page
gptClientGptClientNew — the resolved AI client for this test. Override with test.use({ gptClient: ... })
storageStateBrowserStorageStateNew — 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:

FactoryProvider
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.

AttachmentFormatWhenDescription
stdouttextAlwaysStandard output captured during the test (Playwright built-in)
stderrtextAlwaysStandard error captured during the test (Playwright built-in)
test-flow-metadata.jsonJSONAlwaysFull flow metadata: run mode, tool call count, token usage, start/end times, and final state (SUCCESS / FAILED)
donobu-step-{n}-{toolName}imageAlwaysScreenshot captured after each tool call, keyed by step index and tool name
donobu-step-summaryJSONAlwaysSummary of all tool calls: tool name, page URL, timestamps, success/failure, and a short description of each step's outcome
donobu-triage-evidenceJSONOn failureStructured 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.