Instructions for Playwright Test and TypeScript

Link to Instructions for Playwright Test and TypeScript copied to clipboard

Configuring your tests with Playwright Test and TypeScript

Free Trial
  1. In the root level of your testing folder, install the @axe-core/watcher package and all of its dependencies using npm or your preferred package manager (for example, Yarn or pnpm).

    npm install --save-dev @axe-core/watcher
  2. Create a fixtures.ts file alongside your existing Playwright Test tests. In this file, import the Playwright Test function from @axe-core/watcher:

    import { playwrightTest } from '@axe-core/watcher'
    
    const API_KEY = process.env.API_KEY!
    
    const config = playwrightTest({
      axe: {
        apiKey: API_KEY
      },
      headless: false
      // Any other Playwright configuration you’d pass to chromium.launchPersistentContext() here
    })
    
    export default config
  3. In your test files, replace the imports for test and expect from Playwright Test with your fixtures.ts file:

    import { test, expect } from '@playwright/test'
    // Becomes:
    import { test, expect } from './fixtures';
  4. You're all done.