lighthouse 9.1.0-dev.20211130 → 9.1.0-dev.20211201
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse",
|
|
3
|
-
"version": "9.1.0-dev.
|
|
3
|
+
"version": "9.1.0-dev.20211201",
|
|
4
4
|
"description": "Automated auditing, performance metrics, and best practices for the web.",
|
|
5
5
|
"main": "./lighthouse-core/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
"webtreemap-cdt": "^3.2.1"
|
|
186
186
|
},
|
|
187
187
|
"dependencies": {
|
|
188
|
-
"axe-core": "4.
|
|
188
|
+
"axe-core": "4.3.5",
|
|
189
189
|
"chrome-launcher": "^0.15.0",
|
|
190
190
|
"configstore": "^5.0.1",
|
|
191
191
|
"csp_evaluator": "1.1.0",
|
|
@@ -7,78 +7,73 @@
|
|
|
7
7
|
|
|
8
8
|
/* eslint-env jest */
|
|
9
9
|
|
|
10
|
-
import
|
|
11
|
-
import {jest} from '@jest/globals';
|
|
10
|
+
import puppeteer from 'puppeteer';
|
|
12
11
|
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {CategoryRenderer} from '../../renderer/category-renderer.js';
|
|
17
|
-
import {ReportRenderer} from '../../renderer/report-renderer.js';
|
|
18
|
-
import sampleResultsOrig from '../../../lighthouse-core/test/results/sample_v2.json';
|
|
12
|
+
import sampleResults from '../../../lighthouse-core/test/results/sample_v2.json';
|
|
13
|
+
import reportGenerator from '../../generator/report-generator.js';
|
|
14
|
+
import axeLib from '../../../lighthouse-core/lib/axe.js';
|
|
19
15
|
|
|
20
16
|
describe('ReportRendererAxe', () => {
|
|
21
17
|
describe('with aXe', () => {
|
|
22
|
-
let
|
|
23
|
-
let renderer;
|
|
24
|
-
let sampleResults;
|
|
18
|
+
let browser;
|
|
25
19
|
|
|
26
20
|
beforeAll(async () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const {window} = new jsdom.JSDOM();
|
|
30
|
-
const dom = new DOM(window.document);
|
|
31
|
-
const detailsRenderer = new DetailsRenderer(dom);
|
|
32
|
-
const categoryRenderer = new CategoryRenderer(dom, detailsRenderer);
|
|
33
|
-
renderer = new ReportRenderer(dom, categoryRenderer);
|
|
34
|
-
sampleResults = Util.prepareReportResult(sampleResultsOrig);
|
|
35
|
-
|
|
36
|
-
// Needed by axe-core
|
|
37
|
-
// https://github.com/dequelabs/axe-core/blob/581c441c/doc/examples/jsdom/test/a11y.js#L24
|
|
38
|
-
global.window = global.self = window;
|
|
39
|
-
global.Node = global.self.Node;
|
|
40
|
-
global.Element = global.self.Element;
|
|
41
|
-
|
|
42
|
-
// axe-core must be imported after the global polyfills
|
|
43
|
-
axe = (await import('axe-core')).default;
|
|
21
|
+
browser = await puppeteer.launch();
|
|
44
22
|
});
|
|
45
23
|
|
|
46
|
-
afterAll(() => {
|
|
47
|
-
|
|
48
|
-
global.Node = undefined;
|
|
49
|
-
global.Element = undefined;
|
|
24
|
+
afterAll(async () => {
|
|
25
|
+
await browser.close();
|
|
50
26
|
});
|
|
51
27
|
|
|
52
28
|
it('renders without axe violations', async () => {
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
renderer._dom.document().body.appendChild(container);
|
|
29
|
+
const page = await browser.newPage();
|
|
30
|
+
const htmlReport = reportGenerator.generateReportHtml(sampleResults);
|
|
31
|
+
await page.setContent(htmlReport);
|
|
57
32
|
|
|
33
|
+
// Superset of Lighthouse's aXe config
|
|
58
34
|
const config = {
|
|
35
|
+
runOnly: {
|
|
36
|
+
type: 'tag',
|
|
37
|
+
values: [
|
|
38
|
+
'wcag2a',
|
|
39
|
+
'wcag2aa',
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
resultTypes: ['violations', 'inapplicable'],
|
|
59
43
|
rules: {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
// The following rules are disable for axe-core + jsdom compatibility
|
|
66
|
-
// https://github.com/dequelabs/axe-core/tree/b573b1c1/doc/examples/jest_react#to-run-the-example
|
|
67
|
-
'color-contrast': {enabled: false},
|
|
68
|
-
'link-in-text-block': {enabled: false},
|
|
69
|
-
// Report has empty links prior to i18n-ing.
|
|
70
|
-
'link-name': {enabled: false},
|
|
71
|
-
// May not be a real issue. https://github.com/dequelabs/axe-core/issues/2958
|
|
72
|
-
'nested-interactive': {enabled: false},
|
|
44
|
+
'tabindex': {enabled: true},
|
|
45
|
+
'accesskeys': {enabled: true},
|
|
46
|
+
'heading-order': {enabled: true},
|
|
47
|
+
'meta-viewport': {enabled: true},
|
|
48
|
+
'aria-treeitem-name': {enabled: true},
|
|
73
49
|
},
|
|
74
50
|
};
|
|
75
51
|
|
|
76
|
-
|
|
77
|
-
|
|
52
|
+
await page.evaluate(axeLib.source);
|
|
53
|
+
// eslint-disable-next-line no-undef
|
|
54
|
+
const axeResults = await page.evaluate(config => axe.run(config), config);
|
|
55
|
+
|
|
56
|
+
expect(axeResults.violations).toMatchObject([
|
|
57
|
+
// Color contrast failure only pops up if this pptr is run headfully.
|
|
58
|
+
// There are currently 27 problematic nodes, primarily audit display text and explanations.
|
|
59
|
+
// TODO: fix these failures, regardless.
|
|
60
|
+
// {
|
|
61
|
+
// id: 'color-contrast',
|
|
62
|
+
// },
|
|
63
|
+
{
|
|
64
|
+
id: 'duplicate-id',
|
|
65
|
+
nodes: [
|
|
66
|
+
// We use these audits in multiple categories. Makes sense.
|
|
67
|
+
{html: '<div class="lh-audit lh-audit--binary lh-audit--pass" id="viewport">'},
|
|
68
|
+
{html: '<div class="lh-audit lh-audit--binary lh-audit--fail" id="image-alt">'},
|
|
69
|
+
{html: '<div class="lh-audit lh-audit--binary lh-audit--pass" id="document-title">'},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
]);
|
|
78
73
|
},
|
|
79
|
-
// This test takes
|
|
74
|
+
// This test takes 10s on fast hardware, but can take longer in CI.
|
|
80
75
|
// https://github.com/dequelabs/axe-core/tree/b573b1c1/doc/examples/jest_react#timeout-issues
|
|
81
|
-
/* timeout= */
|
|
76
|
+
/* timeout= */ 20_000
|
|
82
77
|
);
|
|
83
78
|
});
|
|
84
79
|
});
|