Istruzioni per Playwright Test e TypeScript
Configurazione dei test con Playwright Test e TypeScript
-
Nella cartella principale del tuo ambiente di test, installa il pacchetto
@axe-core/watchere tutte le sue dipendenze utilizzandonpmo il tuo gestore di pacchetti preferito (ad esempio,yarnopnpm).npm install --save-dev @axe-core/watcher -
Crea un file
fixtures.tsaccanto ai tuoi test esistenti di Playwright Test. In questo file, importa la funzioneplaywrightTest()da@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 SERVER_URL = process.env.SERVER_URL const { test, expect } = playwrightTest({ axe: { apiKey: ACCESSIBILITY_API_KEY, projectId: PROJECT_ID, serverURL: SERVER_URL }, headless: false // Any other Playwright configuration you’d pass to chromium.launchPersistentContext() here }) export { test, expect }Assicurati di impostare
ACCESSIBILITY_API_KEYePROJECT_IDnel tuo ambiente con la tua chiave API personale (trovata nel tuo account axe, nella scheda **API KEYS**) e con il tuo ID progetto (mostrato in cima a queste istruzioni quando hai creato il tuo progetto o disponibile nella pagina Progetti selezionando **Configura progetto** sotto **Impostazioni**). Se la tua organizzazione utilizza una versione regionale, cloud privata o un'istanza Axe Developer Hub on-premises, imposta ancheSERVER_URLall'URL base di quella istanza (ad esempio,https://axe-eu.deque.com); altrimenti, omettiSERVER_URLe verrà utilizzato il valore predefinitohttps://axe.deque.com. -
Nei tuoi file di test, sostituisci gli import di
testeexpectda Playwright Test con il tuo filefixtures.ts:import { test, expect } from '@playwright/test' // Becomes: import { test, expect } from './fixtures'; -
Hai fatto tutto.
