Course lesson
Write Better Unit Tests with react-testing-library and jest-axe
We can add accessibility testing to our jest unit tests with jest-axe which gives us:
- Duration
- 2 min
- Access
- Pro
- Transcript
- Available
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 react-testing-library to render the components for jest-axe to audit for accessibility.
The React Testing Library is a very light-weight solution for testing React components. It provides light utility functions on top of react-dom and react-dom/test-utils, in a way that encourages better testing practices.
Resources
- jest-axe: https://github.com/nickcolley/jest-axe
- react-testing-library: https://testing-library.com/docs/react-testing-library/intro/