
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
expect-axe-playwright
Advanced tools
Expect matchers to perform Axe accessibility tests in your Playwright tests.
Expect matchers to perform Axe accessibility tests in your Playwright tests.
npm install expect-axe-playwright
yarn add expect-axe-playwright
// playwright.config.ts
import { expect } from '@playwright/test'
import matchers from 'expect-axe-playwright'
expect.extend(matchers)
This project was inspired by
axe-playwright which did a
great job of integrating the axe-core
library with some simple wrapper functions. However, the API is not as elegant
for testing as would be preferred. That's where expect-axe-playwright comes to
the rescue with the following features.
expect API for simplicity and better error
messaging.Here are a few examples:
await expect(page).toPassAxe() // Page
await expect(page.locator('#foo')).toPassAxe() // Locator
await expect(page.frameLocator('iframe')).toPassAxe() // Frame locator
toPassAxeThis function checks if a given page, frame, or element handle passes a set of accessibility checks.
You can test the entire page:
await expect(page).toPassAxe()
Or pass a locator to test part of the page:
await expect(page.locator('#my-element')).toPassAxe()
You can also pass an Axe results object to the matcher:
import { waitForAxeResults } from 'expect-axe-playwright'
test('should pass common accessibility checks', async ({ page }) => {
const { results } = await waitForAxeResults(page)
await expect(results).toPassAxe()
})
toPassAxe() !== toBeAccessible()
It's important to keep in mind that if your page passes the set of accessibility checks that you've configured for Axe, that does not mean that your page is free of all accessibility barriers.
In fact, automated testing can only catch a fraction of the most common kinds of accessibility errors.
Accessibility is analogous in ways to security. Imagine the following code:
expect(myApp).toBeSecure()
It's very hard to say that anything is secure because you never know when someone is going to uncover a security vulnerability in your code. Similarly, it's very hard to say that anything you've built is totally accessible because you never know when somebody will uncover a barrier you didn't know was there.
Furthermore, of the commonly known accessibility barriers, only some can be found through automated testing, which is then further subject to the effectiveness of the checker being used. A 2017 study on the effectiveness of automated accessibility testing tools by the UK's Government Digital Service confirms this.
To echo jest-axe, tools like Axe are similar to code linters and spell checkers: they can find common issues but cannot guarantee that what you build works for users.
You'll also need to:
You can configure options that should be passed to aXe at the project or assertion level.
To configure a single assertion to use a different set of options, pass an object with the desired arguments to the matcher.
await expect(page).toPassAxe({
rules: {
'color-contrast': { enabled: false },
},
})
To configure the entire project to use a different set of options, specify
options in use.axeOptions in your Playwright config file.
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test'
const config: PlaywrightTestConfig = {
use: {
axeOptions: {
rules: {
'color-contrast': { enabled: false },
},
},
},
}
export default config
You can configure options that should be passed to the aXe HTML reporter at the assertion level.
await expect(page.locator('#my-element')).toPassAxe({
filename: 'my-report.html',
})
This is particularly useful if you need to produce multiple aXe reports within the same test as it would otherwise keep replacing the same report every time you run the assertion.
FAQs
Expect matchers to perform Axe accessibility tests in your Playwright tests.
The npm package expect-axe-playwright receives a total of 2,889 weekly downloads. As such, expect-axe-playwright popularity was classified as popular.
We found that expect-axe-playwright demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.