Installeer op het hoofdniveau van je testmap het @axe-core/watcher pakket en al zijn afhankelijkheden met behulp van npm of je voorkeurspakketmanager (bijvoorbeeld, yarn of pnpm).
npm install --save-dev @axe-core/watcherMaak een fixtures.ts bestand naast uw bestaande Playwright Test-tests. Importeer in dit bestand de playwrightTest() functie van @axe-core/watcher:
import { playwrightTest } from '@axe-core/watcher/playwright-test'
const ACCESSIBILITY_API_KEY = process.env.ACCESSIBILITY_API_KEY
const PROJECT_ID = process.env.PROJECT_ID
const { test, expect } = playwrightTest({
axe: {
apiKey: ACCESSIBILITY_API_KEY,
projectId: PROJECT_ID
},
headless: false
// Any other Playwright configuration you’d pass to chromium.launchPersistentContext() here
})
export { test, expect }Zorg ervoor dat u ACCESSIBILITY_API_KEY en PROJECT_ID in uw omgeving instelt op uw persoonlijke API-sleutel (te vinden in uw axe-account, **API-SLEUTELS** tab) en uw project-ID (weergegeven bovenaan deze instructies toen u uw project aanmaakte of beschikbaar op de projectpagina door te kiezen voor **Project configureren** onder **Instellingen**).
Vervang in uw testbestanden de imports voor test en expect van Playwright Test door uw fixtures.ts bestand:
import { test, expect } from '@playwright/test'
// Becomes:
import { test, expect } from './fixtures';En dat is alles.