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