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