Skip to content

Integrate jest-axe to enable a11y assertions in unit & integration tests#70

Merged
zainfathoni merged 4 commits intomasterfrom
feature/a11y
Aug 23, 2019
Merged

Integrate jest-axe to enable a11y assertions in unit & integration tests#70
zainfathoni merged 4 commits intomasterfrom
feature/a11y

Conversation

@andriawan
Copy link
Collaborator

@andriawan andriawan commented Aug 21, 2019

based on task #55

@andriawan andriawan requested a review from zainfathoni August 21, 2019 06:03
@andriawan andriawan self-assigned this Aug 21, 2019
const { container } = render(<App />)
const results = await axe(container)
expect(results).toHaveNoViolations()
cleanup()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this line, because it will be automatically called since this point: testing-library/react-testing-library#430

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just remove cleanup() line?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

import React from 'react'
import App from '../App'

expect.extend(toHaveNoViolations)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can automatically extend the expect API in every tests automatically by simply adding a single line in our setupTests.js file

@zainfathoni zainfathoni changed the title Improvement a11y a11y improvement Aug 23, 2019
@zainfathoni zainfathoni changed the title a11y improvement Integrate jest-axe Aug 23, 2019
@zainfathoni zainfathoni changed the title Integrate jest-axe Integrate jest-axe to enable a11y assertions in unit & integration tests Aug 23, 2019
@zainfathoni zainfathoni merged commit b028a20 into master Aug 23, 2019
@zainfathoni zainfathoni deleted the feature/a11y branch August 23, 2019 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants