lighthouse 9.5.0-dev.20220626 → 9.5.0-dev.20220629
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/dist/report/bundle.esm.js +7 -6
- package/dist/report/flow.js +24 -24
- package/dist/report/standalone.js +19 -19
- package/flow-report/test/common-test.tsx +5 -4
- package/flow-report/test/flow-report-pptr-test.ts +4 -7
- package/flow-report/test/run-flow-report-tests.sh +20 -0
- package/flow-report/test/setup/env-setup.ts +44 -24
- package/flow-report/test/sidebar/sidebar-test.tsx +0 -1
- package/flow-report/test/topbar-test.tsx +5 -5
- package/flow-report/test/util-test.tsx +3 -3
- package/flow-report/tsconfig.json +4 -1
- package/lighthouse-cli/cli-flags.js +313 -305
- package/lighthouse-cli/test/smokehouse/report-assert-test.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +30 -5
- package/lighthouse-core/audits/network-requests.js +79 -62
- package/lighthouse-core/audits/preload-lcp-image.js +33 -7
- package/lighthouse-core/config/config-plugin.js +26 -0
- package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +1 -0
- package/lighthouse-core/gather/gather-runner.js +1 -0
- package/lighthouse-core/gather/gatherers/main-document-content.js +0 -2
- package/lighthouse-core/lib/dependency-graph/network-node.js +1 -1
- package/lighthouse-core/lib/lh-env.js +1 -1
- package/lighthouse-core/lib/navigation-error.js +26 -7
- package/lighthouse-core/util-commonjs.js +7 -6
- package/package.json +24 -19
- package/report/renderer/util.js +7 -6
- package/report/test/.eslintrc.cjs +4 -1
- package/report/test/clients/bundle-test.js +4 -4
- package/report/test/generator/report-generator-test.js +3 -1
- package/report/test/renderer/category-renderer-test.js +3 -3
- package/report/test/renderer/components-test.js +36 -34
- package/report/test/renderer/crc-details-renderer-test.js +2 -2
- package/report/test/renderer/details-renderer-test.js +2 -2
- package/report/test/renderer/dom-test.js +4 -4
- package/report/test/renderer/element-screenshot-renderer-test.js +3 -2
- package/report/test/renderer/performance-category-renderer-test.js +4 -4
- package/report/test/renderer/pwa-category-renderer-test.js +3 -3
- package/report/test/renderer/report-renderer-axe-test.js +6 -8
- package/report/test/renderer/report-renderer-test.js +5 -5
- package/report/test/renderer/report-ui-features-test.js +8 -8
- package/report/test/renderer/snippet-renderer-test.js +2 -2
- package/report/test/renderer/text-encoding-test.js +2 -2
- package/report/test/renderer/util-test.js +1 -1
- package/root.js +0 -18
- package/shared/localization/locales/en-US.json +3 -0
- package/shared/localization/locales/en-XL.json +3 -0
- package/shared/test/localization/.eslintrc.cjs +4 -1
- package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +1 -1
- package/third-party/chromium-synchronization/installability-errors-test.js +1 -3
- package/types/test.d.ts +53 -0
- package/flow-report/jest.config.js +0 -24
- package/flow-report/test/setup/global-setup.ts +0 -11
- package/jest.config.js +0 -30
- package/types/jest.d.ts +0 -25
package/report/renderer/util.js
CHANGED
|
@@ -568,15 +568,16 @@ class Util {
|
|
|
568
568
|
*/
|
|
569
569
|
Util.reportJson = null;
|
|
570
570
|
|
|
571
|
+
let svgSuffix = 0;
|
|
571
572
|
/**
|
|
572
573
|
* An always-increasing counter for making unique SVG ID suffixes.
|
|
573
574
|
*/
|
|
574
|
-
Util.getUniqueSuffix = (
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}
|
|
575
|
+
Util.getUniqueSuffix = () => {
|
|
576
|
+
return svgSuffix++;
|
|
577
|
+
};
|
|
578
|
+
Util.resetUniqueSuffix = () => {
|
|
579
|
+
svgSuffix = 0;
|
|
580
|
+
};
|
|
580
581
|
|
|
581
582
|
/**
|
|
582
583
|
* Report-renderer-specific strings.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import fs from 'fs';
|
|
8
8
|
|
|
9
9
|
import jsdom from 'jsdom';
|
|
10
|
-
import
|
|
10
|
+
import jestMock from 'jest-mock';
|
|
11
11
|
|
|
12
12
|
import * as lighthouseRenderer from '../../clients/bundle.js';
|
|
13
13
|
import {LH_ROOT} from '../../../root.js';
|
|
@@ -17,8 +17,8 @@ const sampleResultsStr =
|
|
|
17
17
|
|
|
18
18
|
describe('lighthouseRenderer bundle', () => {
|
|
19
19
|
let document;
|
|
20
|
-
|
|
21
|
-
global.console.warn =
|
|
20
|
+
before(() => {
|
|
21
|
+
global.console.warn = jestMock.fn();
|
|
22
22
|
|
|
23
23
|
const {window} = new jsdom.JSDOM();
|
|
24
24
|
document = window.document;
|
|
@@ -38,7 +38,7 @@ describe('lighthouseRenderer bundle', () => {
|
|
|
38
38
|
};
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
after(() => {
|
|
42
42
|
global.window = global.self = undefined;
|
|
43
43
|
global.HTMLInputElement = undefined;
|
|
44
44
|
});
|
|
@@ -13,7 +13,9 @@ const fs = require('fs');
|
|
|
13
13
|
const csvValidator = require('csv-validator');
|
|
14
14
|
|
|
15
15
|
const ReportGenerator = require('../../generator/report-generator.js');
|
|
16
|
-
const
|
|
16
|
+
const {readJson} = require('../../../root.js');
|
|
17
|
+
|
|
18
|
+
const sampleResults = readJson('lighthouse-core/test/results/sample_v2.json');
|
|
17
19
|
|
|
18
20
|
describe('ReportGenerator', () => {
|
|
19
21
|
describe('#replaceStrings', () => {
|
|
@@ -13,7 +13,7 @@ import {I18n} from '../../renderer/i18n.js';
|
|
|
13
13
|
import {DOM} from '../../renderer/dom.js';
|
|
14
14
|
import {DetailsRenderer} from '../../renderer/details-renderer.js';
|
|
15
15
|
import {CategoryRenderer} from '../../renderer/category-renderer.js';
|
|
16
|
-
import {readJson} from '../../../
|
|
16
|
+
import {readJson} from '../../../lighthouse-core/test/test-utils.js';
|
|
17
17
|
|
|
18
18
|
const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@ describe('CategoryRenderer', () => {
|
|
|
21
21
|
let renderer;
|
|
22
22
|
let sampleResults;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
before(() => {
|
|
25
25
|
Util.i18n = new I18n('en', {...Util.UIStrings});
|
|
26
26
|
|
|
27
27
|
const {document} = new jsdom.JSDOM().window;
|
|
@@ -32,7 +32,7 @@ describe('CategoryRenderer', () => {
|
|
|
32
32
|
sampleResults = Util.prepareReportResult(sampleResultsOrig);
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
after(() => {
|
|
36
36
|
Util.i18n = undefined;
|
|
37
37
|
});
|
|
38
38
|
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
import fs from 'fs';
|
|
8
8
|
|
|
9
9
|
import jsdom from 'jsdom';
|
|
10
|
-
import expect from 'expect';
|
|
11
10
|
|
|
12
11
|
import {DOM} from '../../renderer/dom.js';
|
|
13
12
|
import {LH_ROOT} from '../../../root.js';
|
|
@@ -82,41 +81,44 @@ async function assertDOMTreeMatches(tmplEl) {
|
|
|
82
81
|
}
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
84
|
+
describe('Components', () => {
|
|
85
|
+
const originalCreateElement = DOM.prototype.createElement;
|
|
86
|
+
const originalCreateElementNS = DOM.prototype.createElementNS;
|
|
87
|
+
|
|
88
|
+
before(() => {
|
|
89
|
+
/**
|
|
90
|
+
* @param {string} classNames
|
|
91
|
+
*/
|
|
92
|
+
function checkPrefix(classNames) {
|
|
93
|
+
if (!classNames) return;
|
|
94
|
+
|
|
95
|
+
for (const className of classNames.split(' ')) {
|
|
96
|
+
if (!className.startsWith('lh-')) {
|
|
97
|
+
throw new Error(`expected classname to start with lh-, got: ${className}`);
|
|
98
|
+
}
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
DOM.prototype.createElement = function(...args) {
|
|
102
|
-
const classNames = args[1];
|
|
103
|
-
checkPrefix(classNames);
|
|
104
|
-
return originalCreateElement.call(this, ...args);
|
|
105
|
-
};
|
|
106
|
-
DOM.prototype.createElementNS = function(...args) {
|
|
107
|
-
const classNames = args[2];
|
|
108
|
-
checkPrefix(classNames);
|
|
109
|
-
return originalCreateElementNS.call(this, ...args);
|
|
110
|
-
};
|
|
111
|
-
});
|
|
112
101
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
102
|
+
DOM.prototype.createElement = function(...args) {
|
|
103
|
+
const classNames = args[1];
|
|
104
|
+
checkPrefix(classNames);
|
|
105
|
+
return originalCreateElement.call(this, ...args);
|
|
106
|
+
};
|
|
107
|
+
DOM.prototype.createElementNS = function(...args) {
|
|
108
|
+
const classNames = args[2];
|
|
109
|
+
checkPrefix(classNames);
|
|
110
|
+
return originalCreateElementNS.call(this, ...args);
|
|
111
|
+
};
|
|
112
|
+
});
|
|
117
113
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
after(() => {
|
|
115
|
+
DOM.prototype.createElement = originalCreateElement;
|
|
116
|
+
DOM.prototype.createElementNS = originalCreateElementNS;
|
|
121
117
|
});
|
|
122
|
-
|
|
118
|
+
|
|
119
|
+
for (const tmpEl of tmplEls) {
|
|
120
|
+
it(`${tmpEl.id} component matches HTML source`, async () => {
|
|
121
|
+
await assertDOMTreeMatches(tmpEl);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
@@ -72,7 +72,7 @@ describe('DetailsRenderer', () => {
|
|
|
72
72
|
let dom;
|
|
73
73
|
let detailsRenderer;
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
before(() => {
|
|
76
76
|
Util.i18n = new I18n('en', {...Util.UIStrings});
|
|
77
77
|
|
|
78
78
|
const {document} = new jsdom.JSDOM().window;
|
|
@@ -80,7 +80,7 @@ describe('DetailsRenderer', () => {
|
|
|
80
80
|
detailsRenderer = new DetailsRenderer(dom);
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
after(() => {
|
|
84
84
|
Util.i18n = undefined;
|
|
85
85
|
});
|
|
86
86
|
|
|
@@ -22,12 +22,12 @@ describe('DetailsRenderer', () => {
|
|
|
22
22
|
renderer = new DetailsRenderer(dom, options);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
before(() => {
|
|
26
26
|
Util.i18n = new I18n('en', {...Util.UIStrings});
|
|
27
27
|
createRenderer();
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
after(() => {
|
|
31
31
|
Util.i18n = undefined;
|
|
32
32
|
});
|
|
33
33
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import {strict as assert} from 'assert';
|
|
8
8
|
|
|
9
|
-
import
|
|
9
|
+
import jestMock from 'jest-mock';
|
|
10
10
|
import jsdom from 'jsdom';
|
|
11
11
|
|
|
12
12
|
import {DOM} from '../../renderer/dom.js';
|
|
@@ -19,20 +19,20 @@ describe('DOM', () => {
|
|
|
19
19
|
let window;
|
|
20
20
|
let nativeCreateObjectURL;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
before(() => {
|
|
23
23
|
Util.i18n = new I18n('en', {...Util.UIStrings});
|
|
24
24
|
window = new jsdom.JSDOM().window;
|
|
25
25
|
|
|
26
26
|
// The Node version of URL.createObjectURL isn't compatible with the jsdom blob type,
|
|
27
27
|
// so we stub it.
|
|
28
28
|
nativeCreateObjectURL = URL.createObjectURL;
|
|
29
|
-
URL.createObjectURL =
|
|
29
|
+
URL.createObjectURL = jestMock.fn(_ => `https://fake-origin/blahblah-blobid`);
|
|
30
30
|
|
|
31
31
|
dom = new DOM(window.document);
|
|
32
32
|
dom.setLighthouseChannel('someChannel');
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
after(() => {
|
|
36
36
|
Util.i18n = undefined;
|
|
37
37
|
URL.createObjectURL = nativeCreateObjectURL;
|
|
38
38
|
});
|
|
@@ -26,14 +26,15 @@ function makeRect(opts) {
|
|
|
26
26
|
describe('ElementScreenshotRenderer', () => {
|
|
27
27
|
let dom;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
before(() => {
|
|
30
30
|
Util.i18n = new I18n('en', {...Util.UIStrings});
|
|
31
31
|
|
|
32
32
|
const {document} = new jsdom.JSDOM().window;
|
|
33
33
|
dom = new DOM(document);
|
|
34
|
+
Util.resetUniqueSuffix();
|
|
34
35
|
});
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
after(() => {
|
|
37
38
|
Util.i18n = undefined;
|
|
38
39
|
});
|
|
39
40
|
|
|
@@ -14,7 +14,7 @@ import URL from '../../../lighthouse-core/lib/url-shim.js';
|
|
|
14
14
|
import {DOM} from '../../renderer/dom.js';
|
|
15
15
|
import {DetailsRenderer} from '../../renderer/details-renderer.js';
|
|
16
16
|
import {PerformanceCategoryRenderer} from '../../renderer/performance-category-renderer.js';
|
|
17
|
-
import {readJson} from '../../../
|
|
17
|
+
import {readJson} from '../../../lighthouse-core/test/test-utils.js';
|
|
18
18
|
|
|
19
19
|
const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
20
20
|
|
|
@@ -23,7 +23,7 @@ describe('PerfCategoryRenderer', () => {
|
|
|
23
23
|
let renderer;
|
|
24
24
|
let sampleResults;
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
before(() => {
|
|
27
27
|
Util.i18n = new I18n('en', {...Util.UIStrings});
|
|
28
28
|
|
|
29
29
|
const {document} = new jsdom.JSDOM().window;
|
|
@@ -36,7 +36,7 @@ describe('PerfCategoryRenderer', () => {
|
|
|
36
36
|
category = sampleResults.categories.performance;
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
after(() => {
|
|
40
40
|
Util.i18n = undefined;
|
|
41
41
|
});
|
|
42
42
|
|
|
@@ -390,7 +390,7 @@ Array [
|
|
|
390
390
|
let getDescriptionsAfterCheckedToggle;
|
|
391
391
|
|
|
392
392
|
describe('works if there is a performance category', () => {
|
|
393
|
-
|
|
393
|
+
before(() => {
|
|
394
394
|
container = renderer.render(category, sampleResults.categoryGroups);
|
|
395
395
|
const metricsAuditGroup = container.querySelector(metricsSelector);
|
|
396
396
|
toggle = metricsAuditGroup.querySelector(toggleSelector);
|
|
@@ -13,7 +13,7 @@ import {I18n} from '../../renderer/i18n.js';
|
|
|
13
13
|
import {DOM} from '../../renderer/dom.js';
|
|
14
14
|
import {DetailsRenderer} from '../../renderer/details-renderer.js';
|
|
15
15
|
import {PwaCategoryRenderer} from '../../renderer/pwa-category-renderer.js';
|
|
16
|
-
import {readJson} from '../../../
|
|
16
|
+
import {readJson} from '../../../lighthouse-core/test/test-utils.js';
|
|
17
17
|
|
|
18
18
|
const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
19
19
|
|
|
@@ -22,7 +22,7 @@ describe('PwaCategoryRenderer', () => {
|
|
|
22
22
|
let pwaRenderer;
|
|
23
23
|
let sampleResults;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
before(() => {
|
|
26
26
|
Util.i18n = new I18n('en', {...Util.UIStrings});
|
|
27
27
|
|
|
28
28
|
const {document} = new jsdom.JSDOM().window;
|
|
@@ -39,7 +39,7 @@ describe('PwaCategoryRenderer', () => {
|
|
|
39
39
|
category = JSON.parse(JSON.stringify(pwaCategory));
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
after(() => {
|
|
43
43
|
Util.i18n = undefined;
|
|
44
44
|
});
|
|
45
45
|
|
|
@@ -8,7 +8,7 @@ import puppeteer from 'puppeteer';
|
|
|
8
8
|
|
|
9
9
|
import reportGenerator from '../../generator/report-generator.js';
|
|
10
10
|
import axeLib from '../../../lighthouse-core/lib/axe.js';
|
|
11
|
-
import {readJson} from '../../../
|
|
11
|
+
import {readJson} from '../../../lighthouse-core/test/test-utils.js';
|
|
12
12
|
|
|
13
13
|
const sampleResults = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
14
14
|
|
|
@@ -16,14 +16,16 @@ describe('ReportRendererAxe', () => {
|
|
|
16
16
|
describe('with aXe', () => {
|
|
17
17
|
let browser;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
before(async () => {
|
|
20
20
|
browser = await puppeteer.launch();
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
after(async () => {
|
|
24
24
|
await browser.close();
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
+
// This test takes 10s on fast hardware, but can take longer in CI.
|
|
28
|
+
// https://github.com/dequelabs/axe-core/tree/b573b1c1/doc/examples/jest_react#timeout-issues
|
|
27
29
|
it('renders without axe violations', async () => {
|
|
28
30
|
const page = await browser.newPage();
|
|
29
31
|
const htmlReport = reportGenerator.generateReportHtml(sampleResults);
|
|
@@ -78,10 +80,6 @@ describe('ReportRendererAxe', () => {
|
|
|
78
80
|
};
|
|
79
81
|
});
|
|
80
82
|
expect(axeSummary).toMatchSnapshot();
|
|
81
|
-
}
|
|
82
|
-
// This test takes 10s on fast hardware, but can take longer in CI.
|
|
83
|
-
// https://github.com/dequelabs/axe-core/tree/b573b1c1/doc/examples/jest_react#timeout-issues
|
|
84
|
-
/* timeout= */ 20_000
|
|
85
|
-
);
|
|
83
|
+
});
|
|
86
84
|
});
|
|
87
85
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {strict as assert} from 'assert';
|
|
8
8
|
|
|
9
9
|
import jsdom from 'jsdom';
|
|
10
|
-
import
|
|
10
|
+
import jestMock from 'jest-mock';
|
|
11
11
|
|
|
12
12
|
import {Util} from '../../renderer/util.js';
|
|
13
13
|
import URL from '../../../lighthouse-core/lib/url-shim.js';
|
|
@@ -15,7 +15,7 @@ import {DOM} from '../../renderer/dom.js';
|
|
|
15
15
|
import {DetailsRenderer} from '../../renderer/details-renderer.js';
|
|
16
16
|
import {CategoryRenderer} from '../../renderer/category-renderer.js';
|
|
17
17
|
import {ReportRenderer} from '../../renderer/report-renderer.js';
|
|
18
|
-
import {readJson} from '../../../
|
|
18
|
+
import {readJson} from '../../../lighthouse-core/test/test-utils.js';
|
|
19
19
|
|
|
20
20
|
const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
21
21
|
|
|
@@ -25,8 +25,8 @@ describe('ReportRenderer', () => {
|
|
|
25
25
|
let renderer;
|
|
26
26
|
let sampleResults;
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
global.console.warn =
|
|
28
|
+
before(() => {
|
|
29
|
+
global.console.warn = jestMock.fn();
|
|
30
30
|
|
|
31
31
|
// Stub out matchMedia for Node.
|
|
32
32
|
global.matchMedia = function() {
|
|
@@ -45,7 +45,7 @@ describe('ReportRenderer', () => {
|
|
|
45
45
|
sampleResults = Util.prepareReportResult(sampleResultsOrig);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
after(() => {
|
|
49
49
|
global.self = undefined;
|
|
50
50
|
global.matchMedia = undefined;
|
|
51
51
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {strict as assert} from 'assert';
|
|
8
8
|
|
|
9
9
|
import jsdom from 'jsdom';
|
|
10
|
-
import
|
|
10
|
+
import jestMock from 'jest-mock';
|
|
11
11
|
|
|
12
12
|
import reportAssets from '../../generator/report-assets.js';
|
|
13
13
|
import {Util} from '../../renderer/util.js';
|
|
@@ -16,7 +16,7 @@ import {DetailsRenderer} from '../../renderer/details-renderer.js';
|
|
|
16
16
|
import {ReportUIFeatures} from '../../renderer/report-ui-features.js';
|
|
17
17
|
import {CategoryRenderer} from '../../renderer/category-renderer.js';
|
|
18
18
|
import {ReportRenderer} from '../../renderer/report-renderer.js';
|
|
19
|
-
import {readJson} from '../../../
|
|
19
|
+
import {readJson} from '../../../lighthouse-core/test/test-utils.js';
|
|
20
20
|
|
|
21
21
|
const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
22
22
|
|
|
@@ -40,8 +40,8 @@ describe('ReportUIFeatures', () => {
|
|
|
40
40
|
return container;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
global.console.warn =
|
|
43
|
+
before(() => {
|
|
44
|
+
global.console.warn = jestMock.fn();
|
|
45
45
|
|
|
46
46
|
// Stub out matchMedia for Node.
|
|
47
47
|
global.matchMedia = function() {
|
|
@@ -80,7 +80,7 @@ describe('ReportUIFeatures', () => {
|
|
|
80
80
|
render(sampleResults);
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
after(() => {
|
|
84
84
|
global.window = undefined;
|
|
85
85
|
global.HTMLElement = undefined;
|
|
86
86
|
global.HTMLInputElement = undefined;
|
|
@@ -105,7 +105,7 @@ describe('ReportUIFeatures', () => {
|
|
|
105
105
|
describe('third-party filtering', () => {
|
|
106
106
|
let container;
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
before(() => {
|
|
109
109
|
const lhr = JSON.parse(JSON.stringify(sampleResults));
|
|
110
110
|
lhr.requestedUrl = lhr.finalUrl = 'http://www.example.com';
|
|
111
111
|
const webpAuditItemTemplate = {
|
|
@@ -283,7 +283,7 @@ describe('ReportUIFeatures', () => {
|
|
|
283
283
|
const getSaveEl = () => dom.find('a[data-action="save-html"]', container);
|
|
284
284
|
expect(getSaveEl().classList.contains('lh-hidden')).toBeTruthy();
|
|
285
285
|
|
|
286
|
-
const getHtmlMock =
|
|
286
|
+
const getHtmlMock = jestMock.fn();
|
|
287
287
|
container = render(sampleResults, {
|
|
288
288
|
getStandaloneReportHTML: getHtmlMock,
|
|
289
289
|
});
|
|
@@ -428,7 +428,7 @@ describe('ReportUIFeatures', () => {
|
|
|
428
428
|
describe('_getNextSelectableNode', () => {
|
|
429
429
|
let createDiv;
|
|
430
430
|
|
|
431
|
-
|
|
431
|
+
before(() => {
|
|
432
432
|
createDiv = () => dom.document().createElement('div');
|
|
433
433
|
});
|
|
434
434
|
|
|
@@ -54,13 +54,13 @@ function makeSnippetDetails({
|
|
|
54
54
|
describe('DetailsRenderer', () => {
|
|
55
55
|
let dom;
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
before(() => {
|
|
58
58
|
Util.i18n = new I18n('en', {...Util.UIStrings});
|
|
59
59
|
const {document} = new jsdom.JSDOM().window;
|
|
60
60
|
dom = new DOM(document);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
after(() => {
|
|
64
64
|
Util.i18n = undefined;
|
|
65
65
|
});
|
|
66
66
|
|
|
@@ -12,11 +12,11 @@ import {TextEncoding} from '../../renderer/text-encoding.js';
|
|
|
12
12
|
import {LH_ROOT} from '../../../root.js';
|
|
13
13
|
|
|
14
14
|
describe('TextEncoding', () => {
|
|
15
|
-
|
|
15
|
+
before(() => {
|
|
16
16
|
global.window = {pako};
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
after(() => {
|
|
20
20
|
global.window = undefined;
|
|
21
21
|
});
|
|
22
22
|
|
|
@@ -8,7 +8,7 @@ import {strict as assert} from 'assert';
|
|
|
8
8
|
|
|
9
9
|
import {Util} from '../../renderer/util.js';
|
|
10
10
|
import {I18n} from '../../renderer/i18n.js';
|
|
11
|
-
import {readJson} from '../../../
|
|
11
|
+
import {readJson} from '../../../lighthouse-core/test/test-utils.js';
|
|
12
12
|
|
|
13
13
|
const sampleResult = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
|
|
14
14
|
|
package/root.js
CHANGED
|
@@ -5,24 +5,6 @@
|
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
-
const fs = require('fs');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
const url = require('url');
|
|
11
|
-
|
|
12
|
-
// import {dirname} from 'path';
|
|
13
|
-
// import {fileURLToPath} from 'url';
|
|
14
|
-
|
|
15
8
|
module.exports = {
|
|
16
9
|
LH_ROOT: __dirname,
|
|
17
|
-
/**
|
|
18
|
-
* Return parsed json object.
|
|
19
|
-
* Resolves path relative to importMeta.url (if provided) or LH_ROOT (if not provided).
|
|
20
|
-
* @param {string} filePath Can be an absolute or relative path.
|
|
21
|
-
* @param {ImportMeta=} importMeta
|
|
22
|
-
*/
|
|
23
|
-
readJson(filePath, importMeta) {
|
|
24
|
-
const dir = importMeta ? path.dirname(url.fileURLToPath(importMeta.url)) : __dirname;
|
|
25
|
-
filePath = path.resolve(dir, filePath);
|
|
26
|
-
return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
27
|
-
},
|
|
28
10
|
};
|
|
@@ -2102,6 +2102,9 @@
|
|
|
2102
2102
|
"lighthouse-core/lib/lh-error.js | urlInvalid": {
|
|
2103
2103
|
"message": "The URL you have provided appears to be invalid."
|
|
2104
2104
|
},
|
|
2105
|
+
"lighthouse-core/lib/navigation-error.js | warningXhtml": {
|
|
2106
|
+
"message": "The page MIME type is XHTML: Lighthouse does not explicitly support this document type"
|
|
2107
|
+
},
|
|
2105
2108
|
"node_modules/lighthouse-stack-packs/packs/amp.js | efficient-animated-content": {
|
|
2106
2109
|
"message": "For animated content, use [`amp-anim`](https://amp.dev/documentation/components/amp-anim/) to minimize CPU usage when the content is offscreen."
|
|
2107
2110
|
},
|
|
@@ -2102,6 +2102,9 @@
|
|
|
2102
2102
|
"lighthouse-core/lib/lh-error.js | urlInvalid": {
|
|
2103
2103
|
"message": "T̂h́ê ÚR̂Ĺ ŷóû h́âv́ê ṕr̂óv̂íd̂éd̂ áp̂ṕêár̂ś t̂ó b̂é îńv̂ál̂íd̂."
|
|
2104
2104
|
},
|
|
2105
|
+
"lighthouse-core/lib/navigation-error.js | warningXhtml": {
|
|
2106
|
+
"message": "T̂h́ê ṕâǵê ḾÎḾÊ t́ŷṕê íŝ X́ĤT́M̂Ĺ: L̂íĝh́t̂h́ôúŝé d̂óêś n̂ót̂ éx̂ṕl̂íĉít̂ĺŷ śûṕp̂ór̂t́ t̂h́îś d̂óĉúm̂én̂t́ t̂ýp̂é"
|
|
2107
|
+
},
|
|
2105
2108
|
"node_modules/lighthouse-stack-packs/packs/amp.js | efficient-animated-content": {
|
|
2106
2109
|
"message": "F̂ór̂ án̂ím̂át̂éd̂ ćôńt̂én̂t́, ûśê [`amp-anim`](https://amp.dev/documentation/components/amp-anim/) t́ô ḿîńîḿîźê ĆP̂Ú ûśâǵê ẃĥén̂ t́ĥé ĉón̂t́êńt̂ íŝ óf̂f́ŝćr̂éêń."
|
|
2107
2110
|
},
|
|
@@ -17,7 +17,7 @@ describe('issueAdded types', () => {
|
|
|
17
17
|
/** @type {Array<LH.Crdp.Audits.InspectorIssueDetails>} */
|
|
18
18
|
let inspectorIssueDetailsTypes;
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
before(async () => {
|
|
21
21
|
const browserProtocolUrl =
|
|
22
22
|
'https://raw.githubusercontent.com/ChromeDevTools/devtools-protocol/master/json/browser_protocol.json';
|
|
23
23
|
const json = await fetch(browserProtocolUrl).then(r => r.json());
|
|
@@ -9,12 +9,10 @@ const fetch = require('node-fetch');
|
|
|
9
9
|
|
|
10
10
|
const InstallableManifestAudit = require('../../lighthouse-core/audits/installable-manifest.js');
|
|
11
11
|
|
|
12
|
-
jest.setTimeout(20_000);
|
|
13
|
-
|
|
14
12
|
describe('installabilityErrors', () => {
|
|
15
13
|
let chromiumErrorIds;
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
before(async () => {
|
|
18
16
|
const installableLoggingGitTilesUrl =
|
|
19
17
|
'https://chromium.googlesource.com/chromium/src/+/main/components/webapps/browser/installable/installable_logging.cc?format=TEXT';
|
|
20
18
|
const resp = await fetch(installableLoggingGitTilesUrl);
|