Write Unit Tests for Accessibility Using jest-axe and enzyme

InstructorErin Doyle

Share this video with your friends

Send Tweet

We can add accessibility testing to our jest unit tests with jest-axe which gives us:

  • An easy way to automate accessibility auditing.
  • The flexibility to audit at any level of our code, as low as an element and as high as a component representing an entire page of our app.
  • A safety net for any accessibility regressions.

Here we'll see how to use jest-axe with enzyme to render the components for jest-axe to audit for accessibility.

Enzyme is a JavaScript Testing utility for React that makes it easier to test your React Components' output. You can also manipulate, traverse, and in some ways simulate runtime given the output.

Resources

  • jest-axe: https://github.com/nickcolley/jest-axe
  • enzyme: https://enzymejs.github.io/enzyme