Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
feat: 🎸 added jest-axe (#2650)
Browse files Browse the repository at this point in the history
Co-authored-by: Claudio Wunder <cwunder@gnome.org>
  • Loading branch information
benhalverson and ovflowd authored Aug 22, 2022
1 parent 8f2e959 commit 371b952
Show file tree
Hide file tree
Showing 4 changed files with 309 additions and 0 deletions.
286 changes: 286 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
"@types/color-string": "^1.5.2",
"@types/elasticlunr": "^0.9.5",
"@types/jest": "^28.1.6",
"@types/jest-axe": "^3.5.4",
"@types/mdx-js__react": "^1.5.5",
"@types/react-click-outside-hook": "^1.0.0",
"@types/react-dom": "^18.0.6",
Expand All @@ -122,6 +123,7 @@
"eslint-plugin-testing-library": "^5.6.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^28.1.3",
"jest-axe": "^6.0.0",
"jest-environment-jsdom": "^28.1.3",
"jest-fetch-mock": "^3.0.3",
"markdown-yaml-metadata-parser": "^3.0.0",
Expand Down
9 changes: 9 additions & 0 deletions test/pages/404.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import React from 'react';
import { render } from '@testing-library/react';
import { axe, toHaveNoViolations } from 'jest-axe';
import NotFound from '../../src/pages/404';
import '../__mocks__/intersectionObserverMock';

expect.extend(toHaveNoViolations);

describe('404 page', () => {
it('renders correctly', () => {
const { container } = render(<NotFound />);
expect(container).toMatchSnapshot();
});

it('has no accessibility violations', async () => {
const { container } = render(<NotFound />);
const results = await axe(container);
expect(results).toHaveNoViolations();
});
});
12 changes: 12 additions & 0 deletions test/pages/download/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { axe, toHaveNoViolations } from 'jest-axe';
import DownloadPage, {
DownloadNodeReleases,
} from '../../../src/pages/download';
Expand All @@ -27,6 +28,7 @@ const nodeReleaseData: DownloadNodeReleases = {
},
};

expect.extend(toHaveNoViolations);
describe('Download page', () => {
it('renders correctly', () => {
const { container } = render(
Expand All @@ -44,4 +46,14 @@ describe('Download page', () => {

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

// TODO: fix this test
it.skip('shold have no a11y violations', async () => {
const { container } = render(
<DownloadPage location={window.location} data={nodeReleaseData} />
);
const results = await axe(container);

expect(results).toHaveNoViolations();
});
});

0 comments on commit 371b952

Please sign in to comment.