Skip to content

Commit

Permalink
Merge pull request #273 from NickColley/update-to-latest-axe
Browse files Browse the repository at this point in the history
Update to latest axe
  • Loading branch information
NickColley authored Jul 10, 2023
2 parents 07e1ef0 + 2500015 commit 5a3f8c6
Show file tree
Hide file tree
Showing 6 changed files with 1,690 additions and 3,161 deletions.
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

0 comments on commit 5a3f8c6

Please sign in to comment.