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. 完了です。