mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-02 15:59:38 +08:00
98e36aa036
As proposed in #22343, the components can be automatically validated for accessibility. This adds a test helper that runs Axe to check for accessibility violations.
16 lines
497 B
TypeScript
16 lines
497 B
TypeScript
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();
|
|
});
|
|
});
|
|
}
|