NickColley / jest-axe

Custom Jest matcher for aXe for testing accessibility ♿️🃏
MIT License
1.06k stars 54 forks source link

Error: Not implemented: navigation (except hash changes) #211

Closed smellai closed 2 years ago

smellai commented 2 years ago

I am getting the following error for the following test with jest-axe:

Error: Not implemented: navigation (except hash changes)

setupTests.st

import '@testing-library/jest-dom/extend-expect';
import 'jest-axe/extend-expect';

The Component mentioned, is mainly rendering a list of links, the main navigation for my application.

Component.test.tsx, without axe check, no exceptions

it('should render correctly the component', () => {
    const { container } = render(<Component {...defaultProps}>Some content</Component>);

    expect(container).toMatchSnapshot();
  });

Component.test.tsx, with axe check, throws exceptions

it('should render correctly the component', async () => {
    const { container } = render(<Component {...defaultProps}>Some content</Component>);

    expect(await axe(container)).toHaveNoViolations();
    expect(container).toMatchSnapshot();
  });

deps:

  "jest": "^27.4.7",
  "jest-axe": "^5.0.1",
  "@testing-library/react": "^12.1.2",
NickColley commented 2 years ago

I think this is more a jsdom issue there's some workarounds in here that should help you, feel free to reopen if you think there's something specific in jest-axe that should be resolved.

https://github.com/jsdom/jsdom/issues/2112

smellai commented 2 years ago

I think this is more a jsdom issue there's some workarounds in here that should help you, feel free to reopen if you think there's something specific in jest-axe that should be resolved.

jsdom/jsdom#2112

Thanks for your reply @nickcolley, but this happens to me only with jest-axe installation, if I remove only jest-axe I don't get the error