Skip to content

Commit ab8306b

Browse files
authored
feat(axe-4.7): update to use axe-core 4.7.2 (#1061)
#### Details This PR upgrades `axe-core` to 4.7.2 according to the instructions in CONTRIBUTING.md. Additionally, it adds a script that uses `@puppeteer/browsers` to install a specific version of Chrome and move it to the default windows install location, which is expected by `ChromeDriver`. It also adds `@axe-core/cli` to dependabot,yml since we want to include it in axe-core upgrades and not before. ##### Motivation feature work 🚀 ##### Context #### Pull request checklist <!-- If a checklist item is not applicable to this change, write "n/a" in the checkbox --> - [x] PR title respects [Conventional Commits](https://www.conventionalcommits.org) (starts with `fix:`, `feat:`, etc, and is suitable for user-facing release notes) - [x] PR contains no breaking changes, **OR** description of both PR **and final merge commit** starts with `BREAKING CHANGE:` - [n/a] (if applicable) Addresses issue: #0000 - [n/a] Added relevant unit tests for your changes - [x] Ran `yarn precheckin` - [x] Verified code coverage for the changes made
1 parent 6bf708c commit ab8306b

18 files changed

+108801
-33
lines changed

.github/dependabot.yml

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ updates:
4444
- dependency-name: "@axe-core/puppeteer"
4545
versions:
4646
- ">= 0"
47+
- dependency-name: "@axe-core/cli"
48+
versions:
49+
- ">= 0"
4750
# Major version of @types/node is pinned to match the version of node we
4851
# use for builds (ideally, latest LTS)
4952
- dependency-name: "@types/node"

CONTRIBUTING.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ To update the package and test cases to account for a new axe-core version:
5353
1. In `package.json`, update the version numbers of the following components:
5454

5555
- `devDependencies` entries for `@axe-core/cli` and `@axe-core/puppeteer`
56-
- `resolutions` entries for `axe-core` and `@axe-core/cli/chromedriver`
56+
- `resolutions` entries for `axe-core`
5757
- **NOT** the `dependencies` entry for `@axe-core`!
5858

5959
1. Build the repo with:
@@ -69,6 +69,28 @@ To update the package and test cases to account for a new axe-core version:
6969
yarn generate-test-resources
7070
```
7171
72+
- If this fails with an error message saying it cannot find the Chrome binary, run:
73+
74+
```
75+
yarn generate-chrome-resources
76+
```
77+
78+
- If this fails with an error message saying "This version of ChromeDriver only supports Chrome version X", then find a version number that starts with X from [this list](https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json) and then run:
79+
80+
```
81+
yarn generate-chrome-resources [version-number]
82+
yarn generate-test-resources
83+
```
84+
85+
for example:
86+
87+
```
88+
yarn generate-chrome-resources 113.0.5672.0
89+
yarn generate-test-resources
90+
```
91+
92+
This script installs the Chrome binary for the specified version of Chrome in the location that ChromeDriver expects it to be (`C:\Users\[username]\AppData\Local\Google\Chrome\Application` on Windows). This will allow you to successfully run the script to generate test resources.
93+
7294
1. Manually compare the diff of `/src/test-resources/basic-axe-vPREVIOUS.sarif` and `/src/test-resources/basic-axe-vNEW.sarif`; the only differences should be the version numbers.
7395
1. Manually compare the diff of `/src/test-resources/w3citylights-axe-vPREVIOUS.sarif` and `/src/test-resources/w3citylights-axe-vNEW.sarif`; in addition to version number differences, you should see some differences based on new/removed rules between the axe versions.
7496
1. Add test cases involving the new files to the integration tests in `src/index.test.ts` and `src/cli.test.ts`

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
},
1717
"packageManager": "[email protected]",
1818
"dependencies": {
19+
"@puppeteer/browsers": "^1.5.0",
1920
"@types/sarif": ">=2.1.1 <=2.1.4",
2021
"axe-core": "^3.2.2 || ^4.0.0",
2122
"yargs": "^17.0.0"
2223
},
2324
"devDependencies": {
24-
"@axe-core/cli": "^4.6.0",
25-
"@axe-core/puppeteer": "^4.6.0",
25+
"@axe-core/cli": "^4.7.0",
26+
"@axe-core/puppeteer": "^4.7.0",
2627
"@types/jest": "^27.4.0",
2728
"@types/lodash": "^4.14.136",
2829
"@types/node": "^18.16.2",
@@ -44,9 +45,8 @@
4445
"typescript": "^4.0.2"
4546
},
4647
"resolutions": {
47-
"@axe-core/cli/chromedriver@^109.0.0": "^111.0.0",
4848
"ansi-regex@^4.1.0": "^5.0.1",
49-
"axe-core": "4.6.3"
49+
"axe-core": "4.7.2"
5050
},
5151
"scripts": {
5252
"prebuild": "yarn clean",
@@ -63,7 +63,8 @@
6363
"semantic-release": "semantic-release",
6464
"generate-test-resources": "yarn generate-axe-core-resources && yarn generate-axe-cli-resources",
6565
"generate-axe-cli-resources": "node dist/test-resources/generator/generate-axe-cli-resources.js",
66-
"generate-axe-core-resources": "node dist/test-resources/generator/generate-axe-core-resources.js"
66+
"generate-axe-core-resources": "node dist/test-resources/generator/generate-axe-core-resources.js",
67+
"generate-chrome-resources": "node dist/test-resources/generator/install-chrome-for-webdriver.js"
6768
},
6869
"repository": {
6970
"type": "git",

src/__snapshots__/index.test.ts.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -1388,15 +1388,15 @@ Object {
13881388
],
13891389
"tool": Object {
13901390
"driver": Object {
1391-
"downloadUri": "https://www.npmjs.com/package/axe-core/v/4.6.3",
1392-
"fullName": "axe for Web v4.6.3",
1391+
"downloadUri": "https://www.npmjs.com/package/axe-core/v/4.7.2",
1392+
"fullName": "axe for Web v4.7.2",
13931393
"informationUri": "https://www.deque.com/axe/axe-for-web/",
13941394
"name": "axe-core",
13951395
"properties": Object {
13961396
"microsoft/qualityDomain": "Accessibility",
13971397
},
13981398
"rules": Array [],
1399-
"semanticVersion": "4.6.3",
1399+
"semanticVersion": "4.7.2",
14001400
"shortDescription": Object {
14011401
"text": "An open source accessibility rules library for automated testing.",
14021402
},
@@ -1407,7 +1407,7 @@ Object {
14071407
"name": "WCAG",
14081408
},
14091409
],
1410-
"version": "4.6.3",
1410+
"version": "4.7.2",
14111411
},
14121412
},
14131413
},

src/cli.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ describe('axe-sarif-converter CLI', () => {
7373
${'w3citylights-axe-v4.4.1.axe-cli-v4.4.2.json'}
7474
${'basic-axe-v4.6.3.axe-cli-v4.6.0.json'}
7575
${'w3citylights-axe-v4.6.3.axe-cli-v4.6.0.json'}
76+
${'basic-axe-v4.7.2.axe-cli-v4.7.3.json'}
77+
${'w3citylights-axe-v4.7.2.axe-cli-v4.7.3.json'}
7678
`(
7779
'supports conversion from axe-cli output $inputFile',
7880
async ({ inputFile }) => {
@@ -194,11 +196,11 @@ describe('axe-sarif-converter CLI', () => {
194196
const testResultsDir = path.join(__dirname, '..', 'test-results');
195197
const basicAxeV2File = path.join(
196198
testResourcesDir,
197-
'basic-axe-v4.4.1.reporter-v2.json',
199+
'basic-axe-v4.7.2.reporter-v2.json',
198200
);
199201
const basicSarifFile = path.join(
200202
testResourcesDir,
201-
'basic-axe-v4.4.1.sarif',
203+
'basic-axe-v4.7.2.sarif',
202204
);
203205

204206
const mkdir = promisify(fs.mkdir);

src/index.test.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ describe('public convertAxeToSarif API', () => {
111111
${'basic-axe-v4.6.3.reporter-v2.json'} | ${'basic-axe-v4.6.3.sarif'}
112112
${'w3citylights-axe-v4.6.3.reporter-v1.json'} | ${'w3citylights-axe-v4.6.3.sarif'}
113113
${'w3citylights-axe-v4.6.3.reporter-v2.json'} | ${'w3citylights-axe-v4.6.3.sarif'}
114+
${'basic-axe-v4.7.2.reporter-v1.json'} | ${'basic-axe-v4.7.2.sarif'}
115+
${'basic-axe-v4.7.2.reporter-v2.json'} | ${'basic-axe-v4.7.2.sarif'}
116+
${'w3citylights-axe-v4.7.2.reporter-v1.json'} | ${'w3citylights-axe-v4.7.2.sarif'}
117+
${'w3citylights-axe-v4.7.2.reporter-v2.json'} | ${'w3citylights-axe-v4.7.2.sarif'}
114118
`(
115119
'converts pinned v1/v2 input $inputFile to pinned output $outputFile',
116120
({ inputFile, outputFile }) => {
@@ -157,7 +161,7 @@ describe('public sarifReporter API', () => {
157161
// it isn't very meaningful to test cases that involve old axe versions here.
158162
it.each`
159163
inputFile | outputFile
160-
${'basic-axe-v4.6.3.reporter-raw.json'} | ${'basic-axe-v4.6.3.sarif'}
164+
${'basic-axe-v4.7.2.reporter-raw.json'} | ${'basic-axe-v4.7.2.sarif'}
161165
`(
162166
'converts pinned raw input $inputFile to pinned output $outputFile',
163167
async ({ inputFile, outputFile }) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
[
2+
{
3+
"testEngine": {
4+
"name": "axe-core",
5+
"version": "4.7.2"
6+
},
7+
"testRunner": {
8+
"name": "axe"
9+
},
10+
"testEnvironment": {
11+
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/113.0.5672.35 Safari/537.36",
12+
"windowWidth": 800,
13+
"windowHeight": 600,
14+
"orientationAngle": 0,
15+
"orientationType": "landscape-primary"
16+
},
17+
"timestamp": "2023-08-03T17:39:25.967Z",
18+
"url": "file:///C:/repos/axe-sarif-converter/src/test-resources/basic.html",
19+
"toolOptions": {
20+
"runOnly": {
21+
"type": "rule",
22+
"values": [
23+
"document-title"
24+
]
25+
},
26+
"reporter": "v1"
27+
},
28+
"inapplicable": [],
29+
"passes": [],
30+
"incomplete": [],
31+
"violations": [
32+
{
33+
"id": "document-title",
34+
"impact": "serious",
35+
"tags": [
36+
"cat.text-alternatives",
37+
"wcag2a",
38+
"wcag242",
39+
"ACT",
40+
"TTv5",
41+
"TT12.a"
42+
],
43+
"description": "Ensures each HTML document contains a non-empty <title> element",
44+
"help": "Documents must have <title> element to aid in navigation",
45+
"helpUrl": "https://dequeuniversity.com/rules/axe/4.7/document-title?application=webdriverjs",
46+
"nodes": [
47+
{
48+
"any": [
49+
{
50+
"id": "doc-has-title",
51+
"data": null,
52+
"relatedNodes": [],
53+
"impact": "serious",
54+
"message": "Document does not have a non-empty <title> element"
55+
}
56+
],
57+
"all": [],
58+
"none": [],
59+
"impact": "serious",
60+
"html": "<html><head></head><body>\n</body></html>",
61+
"target": [
62+
"html"
63+
],
64+
"failureSummary": "Fix any of the following:\n Document does not have a non-empty <title> element"
65+
}
66+
]
67+
}
68+
]
69+
}
70+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
[
2+
{
3+
"id": "document-title",
4+
"result": "failed",
5+
"pageLevel": false,
6+
"impact": "serious",
7+
"tags": [
8+
"cat.text-alternatives",
9+
"wcag2a",
10+
"wcag242",
11+
"ACT",
12+
"TTv5",
13+
"TT12.a"
14+
],
15+
"description": "Ensures each HTML document contains a non-empty <title> element",
16+
"help": "Documents must have <title> element to aid in navigation",
17+
"helpUrl": "https://dequeuniversity.com/rules/axe/4.7/document-title?application=axe-puppeteer",
18+
"inapplicable": [],
19+
"passes": [],
20+
"incomplete": [],
21+
"violations": [
22+
{
23+
"node": {
24+
"selector": [
25+
"html"
26+
],
27+
"source": "<html><head></head><body>\n</body></html>",
28+
"xpath": [
29+
"/html"
30+
],
31+
"ancestry": [
32+
"html"
33+
],
34+
"nodeIndexes": [
35+
0
36+
]
37+
},
38+
"any": [
39+
{
40+
"id": "doc-has-title",
41+
"data": null,
42+
"relatedNodes": [],
43+
"impact": "serious",
44+
"message": "Document does not have a non-empty <title> element"
45+
}
46+
],
47+
"all": [],
48+
"none": [],
49+
"impact": "serious",
50+
"result": "failed"
51+
}
52+
]
53+
}
54+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"testEngine": {
3+
"name": "axe-core",
4+
"version": "4.7.2"
5+
},
6+
"testRunner": {
7+
"name": "axe"
8+
},
9+
"testEnvironment": {
10+
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/101.0.4950.0 Safari/537.36",
11+
"windowWidth": 800,
12+
"windowHeight": 600,
13+
"orientationAngle": 0,
14+
"orientationType": "portrait-primary"
15+
},
16+
"timestamp": "2000-01-02T03:04:05.006Z",
17+
"url": "http://localhost/",
18+
"toolOptions": {
19+
"xpath": true,
20+
"runOnly": {
21+
"type": "rule",
22+
"values": [
23+
"document-title"
24+
]
25+
},
26+
"reporter": "v1"
27+
},
28+
"inapplicable": [],
29+
"passes": [],
30+
"incomplete": [],
31+
"violations": [
32+
{
33+
"id": "document-title",
34+
"impact": "serious",
35+
"tags": [
36+
"cat.text-alternatives",
37+
"wcag2a",
38+
"wcag242",
39+
"ACT",
40+
"TTv5",
41+
"TT12.a"
42+
],
43+
"description": "Ensures each HTML document contains a non-empty <title> element",
44+
"help": "Documents must have <title> element to aid in navigation",
45+
"helpUrl": "https://dequeuniversity.com/rules/axe/4.7/document-title?application=axe-puppeteer",
46+
"nodes": [
47+
{
48+
"any": [
49+
{
50+
"id": "doc-has-title",
51+
"data": null,
52+
"relatedNodes": [],
53+
"impact": "serious",
54+
"message": "Document does not have a non-empty <title> element"
55+
}
56+
],
57+
"all": [],
58+
"none": [],
59+
"impact": "serious",
60+
"html": "<html><head></head><body>\n</body></html>",
61+
"target": [
62+
"html"
63+
],
64+
"xpath": [
65+
"/html"
66+
],
67+
"failureSummary": "Fix any of the following:\n Document does not have a non-empty <title> element"
68+
}
69+
]
70+
}
71+
]
72+
}

0 commit comments

Comments
 (0)