storybook/docs/snippets/react/accessibility-testing-with-jest-axe.js.mdx
2021-11-02 19:48:55 +00:00

23 lines
542 B
Plaintext

```js
// MyComponent.test.js
import { render } from '@testing-library/react';
import { composeStories } from '@storybook/testing-react';
import { axe, toHaveNoViolations } from 'jest-axe';
import * as MyComponentStories from './MyComponent.stories';
const { Accessible } = composeStories(MyComponentStories);
expect.extend(toHaveNoViolations);
test('Example accessiblity test', async () => {
const { container } = render(<Accessible />);
const AxeResults = await axe(container);
expect(AxeResults).toHaveNoViolations();
});
```