npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vi-axe

v0.0.5

Published

Modern Vitest matcher for aXe for testing accessibility using axe-core

Readme

vi-axe

A modern fork / rewrite of jest-axe for vitest.

I'm aware that vitest-axe also exists, however it seems to be unmaintained.

npm version node

Custom Vitest matcher for aXe to test accessibility in your components and pages.

Installation

pnpm add -D vi-axe
# or
npm install -D vi-axe
# or
yarn add -D vi-axe

Setup

Configure Vitest so the toHaveNoViolations matcher is available in all tests. In your Vitest config (e.g. vitest.config.ts):

import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    environment: "jsdom", // required for axe
    setupFiles: ["vi-axe/extend-expect"],
  },
});

Alternatively, in a single test file:

import "vi-axe/extend-expect";

Usage

Basic

Run axe on an HTML string or DOM element, then assert there are no violations:

import { axe } from "vi-axe";

test("has no a11y violations", async () => {
  const html = `<main><a href="https://example.com">Example</a></main>`;
  const results = await axe(html);
  expect(results).toHaveNoViolations();
});

With React Testing Library

Pass the rendered container (or any element) to axe:

import { render } from "@testing-library/react";
import { axe } from "vi-axe";

test("component has no a11y violations", async () => {
  const { container } = render(<MyComponent />);
  const results = await axe(container);
  expect(results).toHaveNoViolations();
});

With Vue Test Utils

Pass the wrapper element:

import { mount } from "@vue/test-utils";
import { axe } from "vi-axe";

test("component has no a11y violations", async () => {
  const wrapper = mount(MyComponent);
  const results = await axe(wrapper.element);
  expect(results).toHaveNoViolations();
});

Custom configuration

Use configureAxe to create an axe runner with default options. You can pass axe-core run options and vi-axe-specific options:

import { configureAxe } from "vi-axe";

const axe = configureAxe({
  globalOptions: {
    rules: [{ id: "link-name", enabled: false }],
  },
});

test("custom axe run", async () => {
  const results = await axe("<a href='#'></a>");
  expect(results).toHaveNoViolations();
});

Per-run options can be passed as the second argument:

const results = await axe(html, {
  rules: { "link-name": { enabled: false } },
});

Filtering by impact level

To fail only for certain impact levels (e.g. critical/serious), use impactLevels in configureAxe. The matcher will then consider only violations with those impacts:

import { configureAxe } from "vi-axe";

const axe = configureAxe({
  impactLevels: ["critical", "serious"],
});

Requirements

  • Node: >= 20
  • Vitest with jsdom (or another DOM environment); axe needs a DOM to run.

Color contrast rules are disabled by default in vi-axe because they do not work reliably in jsdom.