Skip to content

Commit 592a6e8

Browse files
chore(deps): update accessibility-checker to 4.0.17 (#22195)
* chore: update accessibility checker deps * fix(config): convert a11y jest matcher to static import * fix(jest): only use accessibility-checker in jsdom environment --------- Co-authored-by: Heloise Lui <71858203+heloiselui@users.noreply.github.com>
1 parent 48c6c79 commit 592a6e8

7 files changed

Lines changed: 68 additions & 64 deletions

File tree

config/jest-config-carbon/matchers/toHaveNoACViolations.js

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,33 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
let aCheckerPromise = null;
8+
import * as aChecker from 'accessibility-checker';
99

10-
async function toHaveNoACViolations(node, label) {
11-
if (aCheckerPromise === null) {
12-
aCheckerPromise = (async () => {
13-
const aChecker = await import('accessibility-checker');
14-
15-
const denylist = new Set([
16-
'html_lang_exists',
17-
'page_title_exists',
18-
'skip_main_exists',
19-
'html_skipnav_exists',
20-
'aria_content_in_landmark',
21-
'aria_child_tabbable',
22-
]);
23-
const ruleset = await aChecker.getRuleset('IBM_Accessibility');
24-
const customRuleset = JSON.parse(JSON.stringify(ruleset));
10+
const aCheckerPromise = (async () => {
11+
const denylist = new Set([
12+
'html_lang_exists',
13+
'page_title_exists',
14+
'skip_main_exists',
15+
'html_skipnav_exists',
16+
'aria_content_in_landmark',
17+
'aria_child_tabbable',
18+
]);
19+
const ruleset = await aChecker.getRuleset('IBM_Accessibility');
20+
const customRuleset = JSON.parse(JSON.stringify(ruleset));
2521

26-
customRuleset.id = 'Custom_Ruleset';
27-
customRuleset.checkpoints = customRuleset.checkpoints.map(
28-
(checkpoint) => {
29-
checkpoint.rules = checkpoint.rules.filter((rule) => {
30-
return !denylist.has(rule.id);
31-
});
32-
return checkpoint;
33-
}
34-
);
22+
customRuleset.id = 'Custom_Ruleset';
23+
customRuleset.checkpoints = customRuleset.checkpoints.map((checkpoint) => {
24+
checkpoint.rules = checkpoint.rules.filter((rule) => {
25+
return !denylist.has(rule.id);
26+
});
27+
return checkpoint;
28+
});
3529

36-
aChecker.addRuleset(customRuleset);
37-
return aChecker;
38-
})();
39-
}
30+
aChecker.addRuleset(customRuleset);
31+
return aChecker;
32+
})();
4033

34+
async function toHaveNoACViolations(node, label) {
4135
const aChecker = await aCheckerPromise;
4236
let results = await aChecker.getCompliance(node, label);
4337
if (aChecker.assertCompliance(results.report) === 0) {

config/jest-config-carbon/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@babel/preset-env": "^7.27.2",
2929
"@babel/preset-react": "^7.27.1",
3030
"@babel/runtime": "^7.27.3",
31-
"accessibility-checker": "^4.0.7",
31+
"accessibility-checker": "^4.0.17",
3232
"axe-core": "^4.10.3",
3333
"babel-jest": "^30.0.5",
3434
"chalk": "^5.4.1",

config/jest-config-carbon/setup/setupAfterEnv.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import chalk from 'chalk';
99
import util from 'util';
1010
import toHaveNoAxeViolations from '../matchers/toHaveNoAxeViolations.js';
11-
import toHaveNoACViolations from '../matchers/toHaveNoACViolations.js';
1211

1312
import '@testing-library/jest-dom';
1413

@@ -23,10 +22,20 @@ import '@testing-library/jest-dom';
2322
//
2423
// For more information, check out the docs here:
2524
// https://jestjs.io/docs/en/configuration.html#setupfilesafterenv-array
26-
expect.extend({
25+
const customMatchers = {
2726
toHaveNoAxeViolations,
28-
toHaveNoACViolations,
29-
});
27+
};
28+
29+
if (global.window && global.document) {
30+
// accessibility-checker registers Jest hooks when imported and pulls in
31+
// filesystem modules. Keep it out of node-only tests that mock `fs`.
32+
const {
33+
default: toHaveNoACViolations,
34+
} = require('../matchers/toHaveNoACViolations.js');
35+
customMatchers.toHaveNoACViolations = toHaveNoACViolations;
36+
}
37+
38+
expect.extend(customMatchers);
3039

3140
// Have our test suite throw an error if one of the below console methods are
3241
// called when we are not expecting them. This is often helpful for React

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"@testing-library/user-event": "^14.4.3",
6262
"@types/prop-types": "^15.7.13",
6363
"@types/react-is": "^19.0.0",
64-
"accessibility-checker": "^4.0.7",
64+
"accessibility-checker": "^4.0.17",
6565
"all-contributors-cli": "^6.19.0",
6666
"cross-env": "^10.0.0",
6767
"cross-spawn": "^7.0.0",

packages/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"rimraf": "^6.0.1",
108108
"sass": "^1.93.2",
109109
"storybook": "^10.3.5",
110-
"storybook-addon-accessibility-checker": ">=9.2.0-rc.3",
110+
"storybook-addon-accessibility-checker": ">=9.2.0-rc.4",
111111
"stream-browserify": "^3.0.0",
112112
"tsdown": "^0.21.0",
113113
"typescript-config-carbon": "workspace:^0.9.0",

packages/web-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
"rimraf": "^6.0.1",
102102
"sass": "^1.93.2",
103103
"storybook": "^10.3.5",
104-
"storybook-addon-accessibility-checker": "^9.2.0-rc.3",
104+
"storybook-addon-accessibility-checker": "^9.2.0-rc.4",
105105
"tsdown": "^0.21.0",
106106
"typescript-config-carbon": "workspace:^0.9.0",
107107
"vite": "^7.2.4",

yarn.lock

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,7 @@ __metadata:
19871987
rimraf: "npm:^6.0.1"
19881988
sass: "npm:^1.93.2"
19891989
storybook: "npm:^10.3.5"
1990-
storybook-addon-accessibility-checker: "npm:>=9.2.0-rc.3"
1990+
storybook-addon-accessibility-checker: "npm:>=9.2.0-rc.4"
19911991
stream-browserify: "npm:^3.0.0"
19921992
tabbable: "npm:^6.2.0"
19931993
tsdown: "npm:^0.21.0"
@@ -2200,7 +2200,7 @@ __metadata:
22002200
rimraf: "npm:^6.0.1"
22012201
sass: "npm:^1.93.2"
22022202
storybook: "npm:^10.3.5"
2203-
storybook-addon-accessibility-checker: "npm:^9.2.0-rc.3"
2203+
storybook-addon-accessibility-checker: "npm:^9.2.0-rc.4"
22042204
tsdown: "npm:^0.21.0"
22052205
tslib: "npm:^2.6.3"
22062206
typescript-config-carbon: "workspace:^0.9.0"
@@ -3350,7 +3350,7 @@ __metadata:
33503350
languageName: node
33513351
linkType: hard
33523352

3353-
"@ibm/telemetry-js@npm:^1.10.2, @ibm/telemetry-js@npm:^1.2.1, @ibm/telemetry-js@npm:^1.5.0, @ibm/telemetry-js@npm:^1.5.1, @ibm/telemetry-js@npm:^1.6.1":
3353+
"@ibm/telemetry-js@npm:^1.10.2, @ibm/telemetry-js@npm:^1.2.1, @ibm/telemetry-js@npm:^1.5.0, @ibm/telemetry-js@npm:^1.5.1, @ibm/telemetry-js@npm:^1.6.1, @ibm/telemetry-js@npm:^1.9.1":
33543354
version: 1.11.0
33553355
resolution: "@ibm/telemetry-js@npm:1.11.0"
33563356
bin:
@@ -7590,26 +7590,27 @@ __metadata:
75907590
languageName: node
75917591
linkType: hard
75927592

7593-
"accessibility-checker-engine@npm:^4.0.8":
7594-
version: 4.0.10
7595-
resolution: "accessibility-checker-engine@npm:4.0.10"
7596-
checksum: 10/84098393894031412a17eeeff65489ad7dff9534d728b6fa8267cab92f56dc4e44ce9538d24c6e900c6c182d7b8d1ba1844b5c7936cea79ec295f5f7db8a6c41
7593+
"accessibility-checker-engine@npm:^4.0.10":
7594+
version: 4.0.17
7595+
resolution: "accessibility-checker-engine@npm:4.0.17"
7596+
checksum: 10/83eaa6b127e18508a3566a221eda4a4a6fa3538eda1791612c32ddd52f2a0e227a9935c55f4897f91ef9fdf7cb2cbc7a7e6ce7a760e5474f3fd70f1b6d8ba15c
75977597
languageName: node
75987598
linkType: hard
75997599

7600-
"accessibility-checker@npm:^4.0.7":
7601-
version: 4.0.7
7602-
resolution: "accessibility-checker@npm:4.0.7"
7600+
"accessibility-checker@npm:^4.0.17":
7601+
version: 4.0.17
7602+
resolution: "accessibility-checker@npm:4.0.17"
76037603
dependencies:
7604+
"@ibm/telemetry-js": "npm:^1.9.1"
76047605
chromedriver: "npm:*"
7605-
deep-diff: "npm:^1.0.2"
76067606
exceljs: "npm:^4.3.0"
76077607
js-yaml: "npm:^4.1.0"
7608+
microdiff: "npm:^1.4.0"
76087609
puppeteer: "npm:^22.14.0"
76097610
string-hash: "npm:^1.1.3"
76107611
bin:
76117612
achecker: bin/achecker.js
7612-
checksum: 10/d5397240fc2b7312d88636769f922e7783e33f73a289f3bb045dddfce5d20ed4d823dd642b272dd3144121d8ed712b8f9a704320eb2c8abe955e23d9a5960b65
7613+
checksum: 10/2ae10c94f61f61c45ce831584b0fb9b2dae4c47734e6e163801f97cc8bd7b5d5b97a21fb70be883df88e5ca769b88ed7b65e291c5851c8ef79760ef455847dd8
76137614
languageName: node
76147615
linkType: hard
76157616

@@ -9048,7 +9049,7 @@ __metadata:
90489049
"@testing-library/user-event": "npm:^14.4.3"
90499050
"@types/prop-types": "npm:^15.7.13"
90509051
"@types/react-is": "npm:^19.0.0"
9051-
accessibility-checker: "npm:^4.0.7"
9052+
accessibility-checker: "npm:^4.0.17"
90529053
all-contributors-cli: "npm:^6.19.0"
90539054
cross-env: "npm:^10.0.0"
90549055
cross-spawn: "npm:^7.0.0"
@@ -10548,13 +10549,6 @@ __metadata:
1054810549
languageName: node
1054910550
linkType: hard
1055010551

10551-
"deep-diff@npm:^1.0.2":
10552-
version: 1.0.2
10553-
resolution: "deep-diff@npm:1.0.2"
10554-
checksum: 10/3e496111b5506e7399e8a5441b713b033ade3b9d60faff96a4c47189e460a889de50dab99afdb1dcddebf701a0b6a6bb7743f5090b7a620da12e3391c940f8f3
10555-
languageName: node
10556-
linkType: hard
10557-
1055810552
"deep-eql@npm:^5.0.1":
1055910553
version: 5.0.2
1056010554
resolution: "deep-eql@npm:5.0.2"
@@ -15020,7 +15014,7 @@ __metadata:
1502015014
"@babel/preset-env": "npm:^7.27.2"
1502115015
"@babel/preset-react": "npm:^7.27.1"
1502215016
"@babel/runtime": "npm:^7.27.3"
15023-
accessibility-checker: "npm:^4.0.7"
15017+
accessibility-checker: "npm:^4.0.17"
1502415018
axe-core: "npm:^4.10.3"
1502515019
babel-jest: "npm:^30.0.5"
1502615020
chalk: "npm:^5.4.1"
@@ -17013,6 +17007,13 @@ __metadata:
1701317007
languageName: node
1701417008
linkType: hard
1701517009

17010+
"microdiff@npm:^1.4.0":
17011+
version: 1.5.0
17012+
resolution: "microdiff@npm:1.5.0"
17013+
checksum: 10/ec1ee39b744e0f5140c9d1bcc05e25d2b2c6f6777bda2cbe59627af8aa0da5d8c98cfa5bbd610571b72b6db9e6cf3d120e24782a9870be611ea4fed69ca7bfbf
17014+
languageName: node
17015+
linkType: hard
17016+
1701617017
"micromark-core-commonmark@npm:^2.0.0":
1701717018
version: 2.0.1
1701817019
resolution: "micromark-core-commonmark@npm:2.0.1"
@@ -21618,16 +21619,16 @@ __metadata:
2161821619
languageName: node
2161921620
linkType: hard
2162021621

21621-
"storybook-addon-accessibility-checker@npm:>=9.2.0-rc.3, storybook-addon-accessibility-checker@npm:^9.2.0-rc.3":
21622-
version: 9.2.0-rc.3
21623-
resolution: "storybook-addon-accessibility-checker@npm:9.2.0-rc.3"
21622+
"storybook-addon-accessibility-checker@npm:>=9.2.0-rc.4, storybook-addon-accessibility-checker@npm:^9.2.0-rc.4":
21623+
version: 9.2.0-rc.4
21624+
resolution: "storybook-addon-accessibility-checker@npm:9.2.0-rc.4"
2162421625
dependencies:
2162521626
"@storybook/global": "npm:^5.0.0"
21626-
accessibility-checker-engine: "npm:^4.0.8"
21627+
accessibility-checker-engine: "npm:^4.0.10"
2162721628
axe-core: "npm:^4.2.0"
2162821629
peerDependencies:
21629-
storybook: "workspace:^"
21630-
checksum: 10/05944d120cfc0c3afff6468ead71ce3776c0dadcaa8125010d3d1800c00e23451ae33d0e4e9325062b897b3519ef3d0c7406bcac533c2e024214e8b6a89e6769
21630+
storybook: ^9.2.0
21631+
checksum: 10/a6619ce06c29186200e8e91823c6c915c4bed3a5310417ef5b850b8847937bce67a6201440ab4aae6e194d549eb61d9abf4c6087c6a35e4cd3112a1f2bb1c57b
2163121632
languageName: node
2163221633
linkType: hard
2163321634

0 commit comments

Comments
 (0)