import args from '../../stories/button.stories'
import { createButton } from '../../stories/button'
import { toHaveNoViolations } from 'jest-axe'
const axe = require('../../axe-helper')
expect.extend(toHaveNoViolations)
describe('Button', () => {
// check style types
args.argTypes.style.options.map(s => {
it(`${s} should be accessible`, async () => {
const render = () => createButton({
style: s,
size: 'md',
label: 'Default'
})
// pass anything that outputs html to axe
const html = render()
expect(await axe(html)).toHaveNoViolations()
})
})
// check button sizes
args.argTypes.size.options.map(s => {
it(`${s} should be accessible`, async () => {
const render = () => createButton({
style: 'default',
size: s,
label: 'Default'
})
// pass anything that outputs html to axe
const html = render()
expect(await axe(html)).toHaveNoViolations()
})
})
})
I have a yellow button with low contrast and on other WCAG2AA checkers, it says that it's not good, however, when running the tests, I get that everything has passed.
Otherwise, if for example, I test with an element like <img /> without an alt="" attribute it will correctly show an accessibility issue.
Hello everyone,
First of all thanks for this awesome tool with Jest.
I'm using the following Axe configuration:
And then use it like this:
I have a yellow button with low contrast and on other WCAG2AA checkers, it says that it's not good, however, when running the tests, I get that everything has passed.
Otherwise, if for example, I test with an element like
<img />
without analt=""
attribute it will correctly show an accessibility issue.Any ideas?
Thanks!