Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bun-axe

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bun-axe

Run axe a11y tests in your bun project

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

bun-axe

Run axe a11y tests in your bun project

Install

bun add bun-axe

Usage

Note: Bun currently does not support extend.expect, so this API will be changed once it's supported. This example code is based on this workaround.

import { describe, it, expect } from 'bun:test'
import { axe, toHaveNoViolationsFn } from 'bun-axe'

describe("Test", () => {
  it("should pass a11y test", async () => {
    document.body.innerHTML = `<button>My button</button>`;
    const button = document.querySelector('button');

    expect(toHaveNoViolationsFn(await axe(button)).pass).toBe(true);
  });
})

If you run into an a11y violation, console.log(toHaveNoViolationsFn(await axe(button)).actual) can be used to see the violations. Until bun supports extend.expect there is no other great way to get this currently.

Future

Once bun supports extend.expect you can swap toHaveNoViolationsFn for toHaveNoViolations and test like this:

import { describe, it, expect } from 'bun:test'
import { axe, toHaveNoViolationsFn } from 'bun-axe'

describe("Test", () => {
  it("should pass a11y test", async () => {
    document.body.innerHTML = `<button>My button</button>`;
    const button = document.querySelector('button');

    expect(await axe(button)).toHaveNoViolations()
  });
})

FAQs

Package last updated on 17 Oct 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc