Playwright Test と JavaScript のための手順

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 と JavaScript を使ったテストの設定

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

    npm install --save-dev @axe-core/watcher
  2. 既存の Playwright Test テストの隣に fixtures.js ファイルを作成します。このファイルで、 playwrightTest() から関数をインポートします @axe-core/watcher/playwright-test

    const { playwrightTest } = require('@axe-core/watcher/playwright-test')
    
    const ACCESSIBILITY_API_KEY = process.env.ACCESSIBILITY_API_KEY
    const PROJECT_ID = process.env.PROJECT_ID
    
    module.exports = playwrightTest({
      axe: {
        apiKey: ACCESSIBILITY_API_KEY,
        projectId: PROJECT_ID
      },
      headless: false,
      // Any other Playwright configuration you’d pass to chromium.launchPersistentContext() here
    })

    必ず、ACCESSIBILITY_API_KEYPROJECT_IDを環境に設定し、あなたの個人用APIキー(AxeアカウントのAPI KEYSタブにあります)とプロジェクトID(プロジェクト作成時のこの手順の上部に表示されるか、プロジェクトページで設定の下にあるプロジェクトを設定を選択することで確認可能です)を使用してください。

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

    const { test, expect } = require('@playwright/test')
    // Becomes:
    const { test, expect } = require('./fixtures')
  4. これで完了です。