How to use jest-axe - 10 common examples

To help you get started, we’ve selected a few jest-axe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github primer / components / src / __tests__ / CircleBadge.js View on Github external
it("should have no axe violations", async () => {
    const {container} = HTMLRender(<CircleBadge variant="large" size={20} />)
    const results = await axe(container)
    expect(results).toHaveNoViolations()
    cleanup()
  })
github primer / components / src / __tests__ / TextInput.js View on Github external
it('should have no axe violations', async () => {
    const {container} = HTMLRender(<TextInput aria-label="zipcode" name="zipcode" variant="small" />)
    const results = await axe(container)
    expect(results).toHaveNoViolations()
    cleanup()
  })
github veteransaffairscanada / vac-benefits-directory / __tests__ / pages / data-validation_tests.js View on Github external
it("passes axe tests", async () => {
    let html = mountedDataValidation().html();
    expect(await axe(html)).toHaveNoViolations();
  });
github twilio-labs / paste / packages / paste-core / components / list / __tests__ / index.spec.tsx View on Github external
it('should have no accessibility violations', async () => {
    const container = document.createElement('div');
    document.body.append(container);
    render(
      <Theme.Provider theme="console">
        <UnorderedList>
          <ListItem>item</ListItem>
        </UnorderedList>
      </Theme.Provider>,
      container
    );
    const results = await axe(document.body);
    expect(results).toHaveNoViolations();
  });
github nexxtway / react-rainbow / src / components / RadioGroup / __test__ / radioGroup.a11y.spec.js View on Github external
it('should be accessible when both all options and the group have a label', async () => {
        expect.assertions(1);
        const html = ReactDOMServer.renderToString(
            <RadioGroup label="Radio Group Label" options={options} />,
        );
        const results = await axe(html);
        expect(results).toHaveNoViolations();
    });
});
github nexxtway / react-rainbow / src / components / ProgressIndicator / __test__ / progressIndicator.a11y.spec.js View on Github external
it('should be accessible when label is passed', async () => {
        expect.assertions(1);
        const html = ReactDOMServer.renderToString(
            <ProgressIndicator>
                <ProgressStep name="step-1" label="Step 1" />
                <ProgressStep name="step-2" label="Step 2" />
                <ProgressStep name="step-3" label="Step 3" />
                <ProgressStep name="step-4" label="Step 4" />
                <ProgressStep name="step-5" label="Step 5" />
            </ProgressIndicator>,
        );
        const results = await axe(html);
        expect(results).toHaveNoViolations();
    });
    it('should be accessible when label is not passed', async () => {
github First-Peoples-Cultural-Council / fv-web-ui / frontend / app / assets / javascripts / views / pages / explore / dialect / Contributor / __tests__ / index.js View on Github external
test('Accessibility', async() => {
    const html = ReactDOMServer.renderToString(<Contributor {...props} />)
    const results = await axe(html)
    expect(results).toHaveNoViolations()
  })
})
github primer / components / src / __tests__ / Tooltip.js View on Github external
it('should have no axe violations', async () => {
    const {container} = HTMLRender(<Tooltip text="hi" />)
    const results = await axe(container)
    expect(results).toHaveNoViolations()
    cleanup()
  })
github DefinitelyTyped / DefinitelyTyped / types / jest-axe / jest-axe-tests.ts View on Github external
import { configureAxe, axe, toHaveNoViolations, JestAxe } from 'jest-axe';

expect.extend(toHaveNoViolations);

const newJestWithDefaults: JestAxe = configureAxe();

const newJestWithOptions: JestAxe = configureAxe({
    elementRef: false,
    iframes: false,
    rules: {},
    runOnly: {
        type: 'rules',
        values: [],
    },
    selectors: false,
});

const sameJest: JestAxe = axe;

expect('').toHaveNoViolations();
expect(document.body).toHaveNoViolations();
github DefinitelyTyped / DefinitelyTyped / types / jest-axe / jest-axe-tests.ts View on Github external
import { configureAxe, axe, toHaveNoViolations, JestAxe } from 'jest-axe';

expect.extend(toHaveNoViolations);

const newJestWithDefaults: JestAxe = configureAxe();

const newJestWithOptions: JestAxe = configureAxe({
    elementRef: false,
    iframes: false,
    rules: {},
    runOnly: {
        type: 'rules',
        values: [],
    },
    selectors: false,
});

const sameJest: JestAxe = axe;

expect('').toHaveNoViolations();
expect(document.body).toHaveNoViolations();

async () => {

jest-axe

Custom Jest matcher for aXe for testing accessibility

MIT
Latest version published 1 month ago

Package Health Score

83 / 100
Full package analysis

Popular jest-axe functions