forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'accessibility-tests' of https://github.com/StefSchenkel…
…aars/ant-design into StefSchenkelaars-accessibility-tests
- Loading branch information
Showing
6 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { toHaveNoViolations } from 'jest-axe'; | ||
import toMatchRenderedSnapshot from './matchers/rendered-snapshot'; | ||
|
||
expect.extend(toHaveNoViolations); | ||
expect.extend({ | ||
toMatchRenderedSnapshot, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { axe } from 'jest-axe'; | ||
|
||
// eslint-disable-next-line jest/no-export | ||
export default function accessibilityTest(Component: React.ComponentType) { | ||
describe(`accessibility`, () => { | ||
it(`component does not have any violations`, async () => { | ||
jest.useRealTimers(); | ||
const wrapper = mount(<Component />); | ||
const results = await axe(wrapper.getDOMNode()); | ||
expect(results).toHaveNoViolations(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
declare namespace jest { | ||
interface Matchers<R> { | ||
toMatchRenderedSnapshot(): R; | ||
toHaveNoViolations(): R; | ||
} | ||
} |