Accessibility assertions for your test suite

Add WCAG auditing to any Vitest test with a single toBeAccessible() matcher — catch violations at the component level.

View on npm

Features

Component-level testing

Violations are scoped to the element you pass, so you can test components in isolation without noise from the rest of the document.

Clear failure messages

Each violation includes the rule ID, WCAG level, success criterion, and the CSS selector of the offending element.

Same rule engine

Powered by @accesslint/core — 93 WCAG rules, zero dependencies, fast results.

Quick start

npm install --save-dev @accesslint/vitest
// vitest.config.ts
import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    setupFiles: ["@accesslint/vitest"],
  },
});
// component.test.ts
const container = document.createElement("div");
container.innerHTML = '<img src="photo.jpg" alt="A photo">';

expect(container).toBeAccessible();

Works with Storybook

Using Storybook? The AccessLint Storybook addon includes toBeAccessible() in play functions with a dedicated panel, element highlighting, and CI integration.