Instruções para Playwright Test e TypeScript

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard

Configurando seus testes com Playwright Test e TypeScript

Not for use with personal data
  1. No nível raiz da sua pasta de testes, instale o pacote @axe-core/watcher e todas as suas dependências usando o npm ou seu gerenciador de pacotes preferido (por exemplo, yarn ou pnpm).

    npm install --save-dev @axe-core/watcher
  2. Crie um arquivo fixtures.ts junto aos seus testes existentes do Playwright Test. Nesse arquivo, importe a função playwrightTest() de @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 }

    Certifique-se de configurar ACCESSIBILITY_API_KEY e PROJECT_ID no seu ambiente com sua chave de API pessoal (encontrada na sua Conta Axe, aba **API KEYS**) e o ID do seu projeto (mostrado no topo destas instruções quando você criou seu projeto ou disponível na página de Projetos escolhendo **Configurar projeto** em **Configurações**). Se sua organização usar uma instância regional, nuvem privada ou local do Axe Developer Hub, também configure SERVER_URL com a URL base dessa instância (por exemplo, https://axe-eu.deque.com); caso contrário, omita SERVER_URL e o padrão https://axe.deque.com será utilizado.

  3. Nos seus arquivos de teste, substitua as importações de test e expect do Playwright Test pelo seu arquivo fixtures.ts:

    import { test, expect } from '@playwright/test'
    
    // Becomes:
    import { test, expect } from './fixtures';
  4. Você já fez tudo.