DEV Community

Discussion on: How to write tests for React in 2020 - part 2

Collapse
 
nickytonline profile image
Nick Taylor • Edited

You would still need to import axe, but that's it, i.e.

import { axe } from 'jest-axe';

And in your test, things would stay the same. i.e.

test('should have no accessiblity violations', async () => {
    const { container } = render(<App />);
    const results = await axe(container);

    expect(results).toHaveNoViolations();
});

It's a small change, but it saves importing it in every file that requires a11y checks.

Looking forward to your next post!