A chai assertion that runs axe-core on an enzyme wrapper object to test for a11y violations.
npm install chai-enzyme-axe
Follow the instructions on using axe-core.
import chai from 'chai'
import ChaiEnzymeAxe from 'chai-enzyme-axe'
chai.use(ChaiEnzymeAxe)
import {mount, render, shallow} from 'enzyme'
class Fixture extends React.Component {
render () {
return (
<div>
<label for="name">Name</label>
<input type="text" id="name" />
</div>
)
}
}
const wrapper = mount(<Fixture />)
wrapper.should.be.accessible(done)