Playwright Testと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

Playwright TestとTypeScriptでテストを構成する

Not for use with personal data
  1. テストフォルダのルートレベルに、 @axe-core/watcher パッケージとそのすべての依存関係をインストールします。 npm またはお好みのパッケージマネージャを使用します(例: yarn または pnpm)。

    npm install --save-dev @axe-core/watcher
  2. 既存のPlaywright Testのテストと並行して fixtures.ts ファイルを作成します。このファイルで、 playwrightTest() から関数をインポートします: @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 }

    必ず環境で ACCESSIBILITY_API_KEYPROJECT_ID を設定し、自分のAPIキー(axeアカウントで見つかります、 **API KEYS** タブ)とプロジェクトID(プロジェクトを作成したときのこれらの指示の上部に表示されるか、 **プロジェクトの構成** を選択してプロジェクトページから利用可能です) **設定**の下にあります。

  3. テストファイルで、 testexpect をPlaywright Testからあなたの fixtures.ts ファイルに置き換えます:

    import { test, expect } from '@playwright/test'
    
    // Becomes:
    import { test, expect } from './fixtures';
  4. 完了です。