Instructions for Playwright Test and JavaScript
Configuring your tests with Playwright Test and JavaScript
Not for use with personal data
-
In the root level of your testing folder, install the
@axe-core/watcher
package and all of its dependencies usingnpm
or your preferred package manager (for example,yarn
orpnpm
).npm install --save-dev @axe-core/watcher
-
Create a
fixtures.js
file alongside your existing Playwright Test tests. In this file, import theplaywrightTest()
function from@axe-core/watcher
:const { playwrightTest } = require('@axe-core/watcher') const API_KEY = process.env.API_KEY module.exports = playwrightTest({ axe: { apiKey: API_KEY }, headless: false, // Any other Playwright configuration you’d pass to chromium.launchPersistentContext() here })
-
In your test files, replace the imports for
test
andexpect
from Playwright Test with yourfixtures.js
file:const { test, expect } = require('@playwright/test') // Becomes: const { test, expect } = require('./fixtures')
-
You're all done.