Skip to content

Integrate with Playwright ​

Keep native expect, locators, page.keyboard, test.step and your existing fixture design. The package adds a test-scoped journey fixture and a separate reporter.

Compose fixtures ​

This example preserves an existing synthetic tenant fixture with native mergeTests:

ts
import { test as base, mergeTests } from '@playwright/test';
import { test as evidenceTest } from 'a11y-journey-evidence';
const existingTest = base.extend<{ tenant: string }>({ tenant: 'synthetic-team' });
export const test = mergeTests(existingTest, evidenceTest);
export const plainTest = existingTest;

Import that composed test in selected tests and import expect from @playwright/test. The runnable dialog and form examples use the custom fixture in their setup assertions.

Start after setup ​

Request journey in the test callback. Navigate or call page.setContent first, then call await journey.start({ root }) once before the actions under observation. There is no assertion wrapper or per-action recording call.

ts
import { expect } from '@playwright/test';
import { test } from './fixtures.js';
import { loadDialog, exerciseDialog, type DialogVariant } from './dialog.js';

for (const variant of ['correct', 'escaping-focus', 'failed-restoration'] as DialogVariant[]) {
  test(`dialog ${variant}`, async ({ page, journey, tenant }) => {
    if (variant !== 'correct') test.fail();
    await test.step('Setup: load synthetic dialog', async () => {
      expect(tenant).toBe('synthetic-team');
      await loadDialog(page, variant);
    });
    await journey.start({ root: page.locator('#dialog') });
    await exerciseDialog(page);
  });
}

root is a native locator on the fixture page's main light-DOM document. Use an unambiguous declared root; a root may mount later, but unresolved capture is reported honestly. Do not use .first() to hide ambiguity.

A requested fixture without start is selected but not started, with incomplete evidence. Starting without executed assertions does not verify behavior. Tests that never request the fixture are unselected and omitted from the evidence report.

Unselected tests ​

Save this optional control.spec.ts alongside the quickstart files:

ts
import { expect } from '@playwright/test';
import { plainTest as test } from './fixtures.js';
test('unselected control', async ({ page, tenant }) => {
  expect(tenant).toBe('synthetic-team');
  await page.setContent('<h1>Unselected control</h1>');
  await expect(page.getByRole('heading')).toHaveText('Unselected control');
});

It uses the existing fixture but not the package's journey fixture, so it remains visible in native reports and absent from evidence.

Keep native reporters ​

The reporter subpath works beside Playwright's own reporters:

ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
  testDir: '.', testMatch: '*.spec.ts', workers: 1,
  timeout: 15_000, expect: { timeout: 1_000 },
  outputDir: '.artifacts/results',
  reporter: [
    ['list'], ['json', { outputFile: '.artifacts/native.json' }],
    ['html', { outputFolder: '.artifacts/html', open: 'never' }],
    ['a11y-journey-evidence/reporter', {
      outputDir: '.artifacts/evidence', reproductionCommand: 'npm test',
    }],
  ],
  use: { browserName: 'chromium', trace: 'on', viewport: { width: 1280, height: 720 } },
});

This example enables native traces for all attempts, including expected failures. The evidence reporter preserves available native traces in its portable bundle. Trace configuration remains Playwright's responsibility.

Independent capture controls ​

Screenshots and scoped ARIA snapshots default to enabled on actual failures. Disable either independently when starting:

ts
await journey.start({
  root: page.locator('#dialog'),
  screenshots: false,
  ariaSnapshots: true,
  maxObservations: 500,
});

These options control capture; they do not sanitize native titles, diagnostics, screenshots, snapshots or traces. The reference describes defaults, restrictions and capture timing. The limitations guide explains the supported scope and data risks.

Experimental v0.1.0 · External validation pending