Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest axe #273

Merged
merged 3 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions __tests__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Fix any of the following:
Element's default semantics were not overridden with role="none" or role="presentation"

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/image-alt?application=axeAPI
https://dequeuniversity.com/rules/axe/4.7/image-alt?application=axeAPI

────────

Expand All @@ -35,7 +35,7 @@ Fix any of the following:
Some page content is not contained by landmarks

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/region?application=axeAPI"
https://dequeuniversity.com/rules/axe/4.7/region?application=axeAPI"
`;

exports[`jest-axe toHaveNoViolations returns correctly formatted message when violations are present 1`] = `
Expand Down Expand Up @@ -80,7 +80,7 @@ Fix any of the following:
Element's default semantics were not overridden with role="none" or role="presentation"

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/image-alt?application=axeAPI
https://dequeuniversity.com/rules/axe/4.7/image-alt?application=axeAPI

Expected the HTML found at $('img[src="http://example.com/2"]') to have no violations:

Expand All @@ -98,7 +98,7 @@ Fix any of the following:
Element's default semantics were not overridden with role="none" or role="presentation"

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/image-alt?application=axeAPI
https://dequeuniversity.com/rules/axe/4.7/image-alt?application=axeAPI

────────

Expand All @@ -120,7 +120,7 @@ Fix any of the following:
Element's default semantics were not overridden with role="none" or role="presentation"

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/label?application=axeAPI
https://dequeuniversity.com/rules/axe/4.7/label?application=axeAPI

────────

Expand All @@ -142,7 +142,7 @@ Fix any of the following:
Element has no title attribute

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/link-name?application=axeAPI
https://dequeuniversity.com/rules/axe/4.7/link-name?application=axeAPI

Expected the HTML found at $('a[href$="#link-name-2"]') to have no violations:

Expand All @@ -162,7 +162,7 @@ Fix any of the following:
Element has no title attribute

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/link-name?application=axeAPI
https://dequeuniversity.com/rules/axe/4.7/link-name?application=axeAPI

────────

Expand All @@ -178,7 +178,7 @@ Fix any of the following:
Some page content is not contained by landmarks

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/region?application=axeAPI
https://dequeuniversity.com/rules/axe/4.7/region?application=axeAPI

Expected the HTML found at $('img[src="http://example.com/2"]') to have no violations:

Expand All @@ -192,7 +192,7 @@ Fix any of the following:
Some page content is not contained by landmarks

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/region?application=axeAPI
https://dequeuniversity.com/rules/axe/4.7/region?application=axeAPI

Expected the HTML found at $('input') to have no violations:

Expand All @@ -206,5 +206,5 @@ Fix any of the following:
Some page content is not contained by landmarks

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/region?application=axeAPI"
https://dequeuniversity.com/rules/axe/4.7/region?application=axeAPI"
`;
6 changes: 3 additions & 3 deletions __tests__/__snapshots__/reactjs.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Fix any of the following:
Element's default semantics were not overridden with role="none" or role="presentation"

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/image-alt?application=axeAPI"
https://dequeuniversity.com/rules/axe/4.7/image-alt?application=axeAPI"
`;

exports[`React renders correctly 1`] = `
Expand All @@ -41,7 +41,7 @@ Fix any of the following:
Element's default semantics were not overridden with role="none" or role="presentation"

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/image-alt?application=axeAPI
https://dequeuniversity.com/rules/axe/4.7/image-alt?application=axeAPI

────────

Expand All @@ -57,5 +57,5 @@ Fix any of the following:
Some page content is not contained by landmarks

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/region?application=axeAPI"
https://dequeuniversity.com/rules/axe/4.7/region?application=axeAPI"
`;
6 changes: 3 additions & 3 deletions __tests__/__snapshots__/vuejs.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Fix any of the following:
Element's default semantics were not overridden with role="none" or role="presentation"

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/image-alt?application=axeAPI"
https://dequeuniversity.com/rules/axe/4.7/image-alt?application=axeAPI"
`;

exports[`Vue renders correctly 1`] = `
Expand All @@ -41,7 +41,7 @@ Fix any of the following:
Element's default semantics were not overridden with role="none" or role="presentation"

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/image-alt?application=axeAPI
https://dequeuniversity.com/rules/axe/4.7/image-alt?application=axeAPI

────────

Expand All @@ -57,5 +57,5 @@ Fix any of the following:
Some page content is not contained by landmarks

You can find more information on this issue here:
https://dequeuniversity.com/rules/axe/4.5/region?application=axeAPI"
https://dequeuniversity.com/rules/axe/4.7/region?application=axeAPI"
`;
21 changes: 12 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const merge = require("lodash.merge");
const chalk = require("chalk");
const { printReceived, matcherHint } = require("jest-matcher-utils");

const AXE_RULES_COLOR = axeCore.getRules(["cat.color"]);

/**
* Converts a HTML string or HTML element to a mounted HTML element.
* @param {Element | string} a HTML element or a HTML string
Expand Down Expand Up @@ -48,16 +50,17 @@ function configureAxe(options = {}) {

// Set the global configuration for axe-core
// https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axeconfigure
const { checks = [], ...otherGlobalOptions } = globalOptions;
const { rules = [], ...otherGlobalOptions } = globalOptions;

// Color contrast checking doesnt work in a jsdom environment.
// So we need to identify them and disable them by default.
const defaultRules = AXE_RULES_COLOR.map(({ ruleId: id }) => ({
id,
enabled: false,
}));

axeCore.configure({
checks: [
{
// color contrast checking doesnt work in a jsdom environment.
id: "color-contrast",
enabled: false,
},
...checks,
],
rules: [...defaultRules, ...rules],
...otherGlobalOptions,
});

Expand Down
Loading