lighthouse 10.4.0-dev.20230710 → 10.4.0-dev.20230711
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/cli/test/smokehouse/frontends/smokehouse-bin.js +24 -14
- package/cli/test/smokehouse/lighthouse-runners/bundle.d.ts +1 -2
- package/cli/test/smokehouse/lighthouse-runners/bundle.js +8 -19
- package/cli/test/smokehouse/lighthouse-runners/cli.d.ts +1 -2
- package/cli/test/smokehouse/lighthouse-runners/cli.js +3 -7
- package/cli/test/smokehouse/lighthouse-runners/devtools.d.ts +1 -2
- package/cli/test/smokehouse/lighthouse-runners/devtools.js +1 -11
- package/cli/test/smokehouse/readme.md +0 -2
- package/cli/test/smokehouse/report-assert.d.ts +1 -2
- package/cli/test/smokehouse/report-assert.js +2 -19
- package/cli/test/smokehouse/smokehouse.js +3 -32
- package/core/audits/byte-efficiency/render-blocking-resources.js +1 -0
- package/package.json +1 -1
- package/types/internal/smokehouse.d.ts +1 -3
- package/core/audits/metrics/first-contentful-paint-3g.d.ts +0 -15
- package/core/audits/metrics/first-contentful-paint-3g.js +0 -69
|
@@ -136,11 +136,6 @@ async function begin() {
|
|
|
136
136
|
default: false,
|
|
137
137
|
describe: 'Save test artifacts and output verbose logs',
|
|
138
138
|
},
|
|
139
|
-
'legacy-navigation': {
|
|
140
|
-
type: 'boolean',
|
|
141
|
-
default: false,
|
|
142
|
-
describe: 'Use the legacy navigation runner',
|
|
143
|
-
},
|
|
144
139
|
'jobs': {
|
|
145
140
|
type: 'number',
|
|
146
141
|
alias: 'j',
|
|
@@ -218,7 +213,6 @@ async function begin() {
|
|
|
218
213
|
jobs,
|
|
219
214
|
retries,
|
|
220
215
|
isDebug: argv.debug,
|
|
221
|
-
useLegacyNavigation: argv.legacyNavigation,
|
|
222
216
|
lighthouseRunner: runLighthouse,
|
|
223
217
|
takeNetworkRequestUrls,
|
|
224
218
|
setup,
|
|
@@ -229,17 +223,25 @@ async function begin() {
|
|
|
229
223
|
servers?.forEach(s => s.close());
|
|
230
224
|
}
|
|
231
225
|
|
|
226
|
+
let smokehouseOutputDir;
|
|
227
|
+
let testResultsToOutput;
|
|
232
228
|
if (!smokehouseResult.success) {
|
|
233
|
-
const failedTestResults = smokehouseResult.testResults.filter(r => r.failed);
|
|
234
|
-
|
|
235
229
|
// Save failed runs to directory. In CI, this is uploaded as an artifact.
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
230
|
+
smokehouseOutputDir = `${LH_ROOT}/.tmp/smokehouse-failures`;
|
|
231
|
+
testResultsToOutput = smokehouseResult.testResults.filter(r => r.failed);
|
|
232
|
+
} else if (!process.env.CI) {
|
|
233
|
+
// Otherwise, only write to disk in debug mode.
|
|
234
|
+
smokehouseOutputDir = `${LH_ROOT}/.tmp/smokehouse-output`;
|
|
235
|
+
testResultsToOutput = smokehouseResult.testResults;
|
|
236
|
+
}
|
|
239
237
|
|
|
240
|
-
|
|
238
|
+
if (smokehouseOutputDir && testResultsToOutput) {
|
|
239
|
+
fs.rmSync(smokehouseOutputDir, {recursive: true, force: true});
|
|
240
|
+
fs.mkdirSync(smokehouseOutputDir);
|
|
241
|
+
|
|
242
|
+
for (const testResult of testResultsToOutput) {
|
|
241
243
|
for (let i = 0; i < testResult.runs.length; i++) {
|
|
242
|
-
const runDir = `${
|
|
244
|
+
const runDir = `${smokehouseOutputDir}/${i}/${testResult.id}`;
|
|
243
245
|
fs.mkdirSync(runDir, {recursive: true});
|
|
244
246
|
|
|
245
247
|
const run = testResult.runs[i];
|
|
@@ -250,10 +252,18 @@ async function begin() {
|
|
|
250
252
|
if (run.networkRequests) {
|
|
251
253
|
fs.writeFileSync(`${runDir}/networkRequests.txt`, run.networkRequests.join('\n'));
|
|
252
254
|
}
|
|
255
|
+
const config = testDefns.find(test => test.id === testResult.id)?.config;
|
|
256
|
+
if (config) {
|
|
257
|
+
fs.writeFileSync(`${runDir}/config.json`, JSON.stringify(config, null, 2));
|
|
258
|
+
}
|
|
253
259
|
}
|
|
254
260
|
}
|
|
255
261
|
|
|
256
|
-
|
|
262
|
+
console.log(`smokehouse artifacts written to ${smokehouseOutputDir}`);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (!smokehouseResult.success && testResultsToOutput) {
|
|
266
|
+
const cmd = `yarn smoke ${testResultsToOutput.map(r => r.id).join(' ')}`;
|
|
257
267
|
console.log(`rerun failures: ${cmd}`);
|
|
258
268
|
}
|
|
259
269
|
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
* Launch Chrome and do a full Lighthouse run via the Lighthouse DevTools bundle.
|
|
3
3
|
* @param {string} url
|
|
4
4
|
* @param {LH.Config=} config
|
|
5
|
-
* @param {{isDebug?: boolean
|
|
5
|
+
* @param {{isDebug?: boolean}=} testRunnerOptions
|
|
6
6
|
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts, log: string}>}
|
|
7
7
|
*/
|
|
8
8
|
export function runLighthouse(url: string, config?: LH.Config | undefined, testRunnerOptions?: {
|
|
9
9
|
isDebug?: boolean;
|
|
10
|
-
useLegacyNavigation?: boolean;
|
|
11
10
|
} | undefined): Promise<{
|
|
12
11
|
lhr: LH.Result;
|
|
13
12
|
artifacts: LH.Artifacts;
|
|
@@ -19,7 +19,6 @@ import {once} from 'events';
|
|
|
19
19
|
import puppeteer from 'puppeteer-core';
|
|
20
20
|
import ChromeLauncher from 'chrome-launcher';
|
|
21
21
|
|
|
22
|
-
import {CriConnection} from '../../../../core/legacy/gather/connections/cri.js';
|
|
23
22
|
import {LH_ROOT} from '../../../../root.js';
|
|
24
23
|
import {loadArtifacts, saveArtifacts} from '../../../../core/lib/asset-saver.js';
|
|
25
24
|
|
|
@@ -39,7 +38,7 @@ if (!isMainThread && parentPort) {
|
|
|
39
38
|
parentPort?.postMessage({type: 'result', value});
|
|
40
39
|
} catch (err) {
|
|
41
40
|
console.error(err);
|
|
42
|
-
parentPort?.postMessage({type: 'error', value: err});
|
|
41
|
+
parentPort?.postMessage({type: 'error', value: err.toString()});
|
|
43
42
|
}
|
|
44
43
|
})();
|
|
45
44
|
}
|
|
@@ -47,7 +46,7 @@ if (!isMainThread && parentPort) {
|
|
|
47
46
|
/**
|
|
48
47
|
* @param {string} url
|
|
49
48
|
* @param {LH.Config|undefined} config
|
|
50
|
-
* @param {{isDebug?: boolean
|
|
49
|
+
* @param {{isDebug?: boolean}} testRunnerOptions
|
|
51
50
|
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts}>}
|
|
52
51
|
*/
|
|
53
52
|
async function runBundledLighthouse(url, config, testRunnerOptions) {
|
|
@@ -72,10 +71,6 @@ async function runBundledLighthouse(url, config, testRunnerOptions) {
|
|
|
72
71
|
// @ts-expect-error - not worth giving test global an actual type.
|
|
73
72
|
const lighthouse = global.runBundledLighthouse;
|
|
74
73
|
|
|
75
|
-
/** @type {import('../../../../core/index.js')['legacyNavigation']} */
|
|
76
|
-
// @ts-expect-error - not worth giving test global an actual type.
|
|
77
|
-
const legacyNavigation = global.runBundledLighthouseLegacyNavigation;
|
|
78
|
-
|
|
79
74
|
// Launch and connect to Chrome.
|
|
80
75
|
const launchedChrome = await ChromeLauncher.launch();
|
|
81
76
|
const port = launchedChrome.port;
|
|
@@ -83,17 +78,11 @@ async function runBundledLighthouse(url, config, testRunnerOptions) {
|
|
|
83
78
|
// Run Lighthouse.
|
|
84
79
|
try {
|
|
85
80
|
const logLevel = testRunnerOptions.isDebug ? 'verbose' : 'info';
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
} else {
|
|
92
|
-
// Puppeteer is not included in the bundle, we must create the page here.
|
|
93
|
-
const browser = await puppeteer.connect({browserURL: `http://localhost:${port}`});
|
|
94
|
-
const page = await browser.newPage();
|
|
95
|
-
runnerResult = await lighthouse(url, {port, logLevel}, config, page);
|
|
96
|
-
}
|
|
81
|
+
|
|
82
|
+
// Puppeteer is not included in the bundle, we must create the page here.
|
|
83
|
+
const browser = await puppeteer.connect({browserURL: `http://localhost:${port}`});
|
|
84
|
+
const page = await browser.newPage();
|
|
85
|
+
const runnerResult = await lighthouse(url, {port, logLevel}, config, page);
|
|
97
86
|
if (!runnerResult) throw new Error('No runnerResult');
|
|
98
87
|
|
|
99
88
|
return {
|
|
@@ -110,7 +99,7 @@ async function runBundledLighthouse(url, config, testRunnerOptions) {
|
|
|
110
99
|
* Launch Chrome and do a full Lighthouse run via the Lighthouse DevTools bundle.
|
|
111
100
|
* @param {string} url
|
|
112
101
|
* @param {LH.Config=} config
|
|
113
|
-
* @param {{isDebug?: boolean
|
|
102
|
+
* @param {{isDebug?: boolean}=} testRunnerOptions
|
|
114
103
|
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts, log: string}>}
|
|
115
104
|
*/
|
|
116
105
|
async function runLighthouse(url, config, testRunnerOptions = {}) {
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
* Launch Chrome and do a full Lighthouse run via the Lighthouse CLI.
|
|
4
4
|
* @param {string} url
|
|
5
5
|
* @param {LH.Config=} config
|
|
6
|
-
* @param {{isDebug?: boolean
|
|
6
|
+
* @param {{isDebug?: boolean}=} testRunnerOptions
|
|
7
7
|
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts, log: string}>}
|
|
8
8
|
*/
|
|
9
9
|
export function runLighthouse(url: string, config?: LH.Config | undefined, testRunnerOptions?: {
|
|
10
10
|
isDebug?: boolean | undefined;
|
|
11
|
-
useFraggleRock?: boolean | undefined;
|
|
12
11
|
} | undefined): Promise<{
|
|
13
12
|
lhr: LH.Result;
|
|
14
13
|
artifacts: LH.Artifacts;
|
|
@@ -28,7 +28,7 @@ const execFileAsync = promisify(execFile);
|
|
|
28
28
|
* Launch Chrome and do a full Lighthouse run via the Lighthouse CLI.
|
|
29
29
|
* @param {string} url
|
|
30
30
|
* @param {LH.Config=} config
|
|
31
|
-
* @param {{isDebug?: boolean
|
|
31
|
+
* @param {{isDebug?: boolean}=} testRunnerOptions
|
|
32
32
|
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts, log: string}>}
|
|
33
33
|
*/
|
|
34
34
|
async function runLighthouse(url, config, testRunnerOptions = {}) {
|
|
@@ -46,11 +46,11 @@ async function runLighthouse(url, config, testRunnerOptions = {}) {
|
|
|
46
46
|
* @param {string} url
|
|
47
47
|
* @param {string} tmpPath
|
|
48
48
|
* @param {LH.Config=} config
|
|
49
|
-
* @param {{isDebug?: boolean
|
|
49
|
+
* @param {{isDebug?: boolean}=} options
|
|
50
50
|
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts, log: string}>}
|
|
51
51
|
*/
|
|
52
52
|
async function internalRun(url, tmpPath, config, options) {
|
|
53
|
-
const {isDebug = false
|
|
53
|
+
const {isDebug = false} = options || {};
|
|
54
54
|
const localConsole = new LocalConsole();
|
|
55
55
|
|
|
56
56
|
const outputPath = `${tmpPath}/smokehouse.report.json`;
|
|
@@ -67,10 +67,6 @@ async function internalRun(url, tmpPath, config, options) {
|
|
|
67
67
|
'--quiet',
|
|
68
68
|
];
|
|
69
69
|
|
|
70
|
-
if (useLegacyNavigation) {
|
|
71
|
-
args.push('--legacy-navigation');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
70
|
// Config can be optionally provided.
|
|
75
71
|
if (config) {
|
|
76
72
|
const configPath = `${tmpPath}/config.json`;
|
|
@@ -5,12 +5,11 @@
|
|
|
5
5
|
* CHROME_PATH determines which Chrome is used–otherwise the default is puppeteer's chrome binary.
|
|
6
6
|
* @param {string} url
|
|
7
7
|
* @param {LH.Config=} config
|
|
8
|
-
* @param {{isDebug?: boolean
|
|
8
|
+
* @param {{isDebug?: boolean}=} testRunnerOptions
|
|
9
9
|
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts, log: string}>}
|
|
10
10
|
*/
|
|
11
11
|
export function runLighthouse(url: string, config?: LH.Config | undefined, testRunnerOptions?: {
|
|
12
12
|
isDebug?: boolean;
|
|
13
|
-
useLegacyNavigation?: boolean;
|
|
14
13
|
} | undefined): Promise<{
|
|
15
14
|
lhr: LH.Result;
|
|
16
15
|
artifacts: LH.Artifacts;
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
* @fileoverview A runner that launches Chrome and executes Lighthouse via DevTools.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import fs from 'fs';
|
|
12
|
-
import os from 'os';
|
|
13
11
|
import {execFileSync} from 'child_process';
|
|
14
12
|
|
|
15
13
|
import {LH_ROOT} from '../../../../root.js';
|
|
@@ -42,7 +40,7 @@ async function setup() {
|
|
|
42
40
|
* CHROME_PATH determines which Chrome is used–otherwise the default is puppeteer's chrome binary.
|
|
43
41
|
* @param {string} url
|
|
44
42
|
* @param {LH.Config=} config
|
|
45
|
-
* @param {{isDebug?: boolean
|
|
43
|
+
* @param {{isDebug?: boolean}=} testRunnerOptions
|
|
46
44
|
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts, log: string}>}
|
|
47
45
|
*/
|
|
48
46
|
async function runLighthouse(url, config, testRunnerOptions = {}) {
|
|
@@ -52,16 +50,8 @@ async function runLighthouse(url, config, testRunnerOptions = {}) {
|
|
|
52
50
|
const {lhr, artifacts, logs} = await testUrlFromDevtools(url, {
|
|
53
51
|
config,
|
|
54
52
|
chromeFlags,
|
|
55
|
-
useLegacyNavigation: testRunnerOptions.useLegacyNavigation,
|
|
56
53
|
});
|
|
57
54
|
|
|
58
|
-
if (testRunnerOptions.isDebug) {
|
|
59
|
-
const outputDir = fs.mkdtempSync(os.tmpdir() + '/lh-smoke-cdt-runner-');
|
|
60
|
-
fs.writeFileSync(`${outputDir}/lhr.json`, JSON.stringify(lhr));
|
|
61
|
-
fs.writeFileSync(`${outputDir}/artifacts.json`, JSON.stringify(artifacts));
|
|
62
|
-
console.log(`${url} results saved at ${outputDir}`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
55
|
const log = logs.join('') + '\n';
|
|
66
56
|
return {lhr, artifacts, log};
|
|
67
57
|
}
|
|
@@ -118,8 +118,6 @@ All pruning checks:
|
|
|
118
118
|
|
|
119
119
|
- `_minChromiumVersion`
|
|
120
120
|
- `_maxChromiumVersion`
|
|
121
|
-
- `_legacyOnly`
|
|
122
|
-
- `_fraggleRockOnly`
|
|
123
121
|
- `_runner` (set to same value provided to CLI --runner flag, ex: `'devtools'`)
|
|
124
122
|
- `_excludeRunner` (set to same value provided to CLI --runner flag, ex: `'devtools'`)
|
|
125
123
|
|
|
@@ -16,7 +16,7 @@ export type Comparison = {
|
|
|
16
16
|
* summary. Returns count of passed and failed tests.
|
|
17
17
|
* @param {{lhr: LH.Result, artifacts: LH.Artifacts, networkRequests?: string[]}} actual
|
|
18
18
|
* @param {Smokehouse.ExpectedRunnerResult} expected
|
|
19
|
-
* @param {{runner?: string, isDebug?: boolean
|
|
19
|
+
* @param {{runner?: string, isDebug?: boolean}=} reportOptions
|
|
20
20
|
* @return {{passed: number, failed: number, log: string}}
|
|
21
21
|
*/
|
|
22
22
|
export function getAssertionReport(actual: {
|
|
@@ -26,7 +26,6 @@ export function getAssertionReport(actual: {
|
|
|
26
26
|
}, expected: Smokehouse.ExpectedRunnerResult, reportOptions?: {
|
|
27
27
|
runner?: string;
|
|
28
28
|
isDebug?: boolean;
|
|
29
|
-
useLegacyNavigation?: boolean;
|
|
30
29
|
} | undefined): {
|
|
31
30
|
passed: number;
|
|
32
31
|
failed: number;
|
|
@@ -237,11 +237,9 @@ function makeComparison(name, actualResult, expectedResult) {
|
|
|
237
237
|
* @param {LocalConsole} localConsole
|
|
238
238
|
* @param {LH.Result} lhr
|
|
239
239
|
* @param {Smokehouse.ExpectedRunnerResult} expected
|
|
240
|
-
* @param {{runner?: string
|
|
240
|
+
* @param {{runner?: string}=} reportOptions
|
|
241
241
|
*/
|
|
242
242
|
function pruneExpectations(localConsole, lhr, expected, reportOptions) {
|
|
243
|
-
const isLegacyNavigation = reportOptions?.useLegacyNavigation;
|
|
244
|
-
|
|
245
243
|
/**
|
|
246
244
|
* Lazily compute the Chrome version because some reports are explicitly asserting error conditions.
|
|
247
245
|
* @returns {string}
|
|
@@ -295,19 +293,6 @@ function pruneExpectations(localConsole, lhr, expected, reportOptions) {
|
|
|
295
293
|
`Actual Chromium version: ${getChromeVersionString()}`,
|
|
296
294
|
].join(' '));
|
|
297
295
|
remove(key);
|
|
298
|
-
} else if (value._legacyOnly && !isLegacyNavigation) {
|
|
299
|
-
localConsole.log([
|
|
300
|
-
`[${key}] marked legacy only but run is Fraggle Rock, pruning expectation:`,
|
|
301
|
-
JSON.stringify(value, null, 2),
|
|
302
|
-
].join(' '));
|
|
303
|
-
remove(key);
|
|
304
|
-
} else if (value._fraggleRockOnly && isLegacyNavigation) {
|
|
305
|
-
localConsole.log([
|
|
306
|
-
`[${key}] marked Fraggle Rock only but run is legacy, pruning expectation:`,
|
|
307
|
-
JSON.stringify(value, null, 2),
|
|
308
|
-
`Actual channel: ${lhr.configSettings.channel}`,
|
|
309
|
-
].join(' '));
|
|
310
|
-
remove(key);
|
|
311
296
|
} else if (value._runner && reportOptions?.runner !== value._runner) {
|
|
312
297
|
localConsole.log([
|
|
313
298
|
`[${key}] is only for runner ${value._runner}, pruning expectation:`,
|
|
@@ -325,8 +310,6 @@ function pruneExpectations(localConsole, lhr, expected, reportOptions) {
|
|
|
325
310
|
}
|
|
326
311
|
}
|
|
327
312
|
|
|
328
|
-
delete obj._legacyOnly;
|
|
329
|
-
delete obj._fraggleRockOnly;
|
|
330
313
|
delete obj._skipInBundled;
|
|
331
314
|
delete obj._minChromiumVersion;
|
|
332
315
|
delete obj._maxChromiumVersion;
|
|
@@ -483,7 +466,7 @@ function reportAssertion(localConsole, assertion) {
|
|
|
483
466
|
* summary. Returns count of passed and failed tests.
|
|
484
467
|
* @param {{lhr: LH.Result, artifacts: LH.Artifacts, networkRequests?: string[]}} actual
|
|
485
468
|
* @param {Smokehouse.ExpectedRunnerResult} expected
|
|
486
|
-
* @param {{runner?: string, isDebug?: boolean
|
|
469
|
+
* @param {{runner?: string, isDebug?: boolean}=} reportOptions
|
|
487
470
|
* @return {{passed: number, failed: number, log: string}}
|
|
488
471
|
*/
|
|
489
472
|
function getAssertionReport(actual, expected, reportOptions = {}) {
|
|
@@ -53,7 +53,6 @@ const DEFAULT_RETRIES = 0;
|
|
|
53
53
|
async function runSmokehouse(smokeTestDefns, smokehouseOptions) {
|
|
54
54
|
const {
|
|
55
55
|
isDebug,
|
|
56
|
-
useLegacyNavigation,
|
|
57
56
|
jobs = DEFAULT_CONCURRENT_RUNS,
|
|
58
57
|
retries = DEFAULT_RETRIES,
|
|
59
58
|
lighthouseRunner = Object.assign(cliLighthouseRunner, {runnerName: 'cli'}),
|
|
@@ -76,7 +75,6 @@ async function runSmokehouse(smokeTestDefns, smokehouseOptions) {
|
|
|
76
75
|
|
|
77
76
|
const testOptions = {
|
|
78
77
|
isDebug,
|
|
79
|
-
useLegacyNavigation,
|
|
80
78
|
retries,
|
|
81
79
|
lighthouseRunner,
|
|
82
80
|
takeNetworkRequestUrls,
|
|
@@ -133,39 +131,18 @@ function purpleify(str) {
|
|
|
133
131
|
return `${log.purple}${str}${log.reset}`;
|
|
134
132
|
}
|
|
135
133
|
|
|
136
|
-
/**
|
|
137
|
-
* @param {LH.Config=} config
|
|
138
|
-
* @return {LH.Config|undefined}
|
|
139
|
-
*/
|
|
140
|
-
function convertToLegacyConfig(config) {
|
|
141
|
-
if (!config) return config;
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
...config,
|
|
145
|
-
passes: [{
|
|
146
|
-
passName: 'defaultPass',
|
|
147
|
-
pauseAfterFcpMs: config.settings?.pauseAfterFcpMs,
|
|
148
|
-
pauseAfterLoadMs: config.settings?.pauseAfterLoadMs,
|
|
149
|
-
networkQuietThresholdMs: config.settings?.networkQuietThresholdMs,
|
|
150
|
-
cpuQuietThresholdMs: config.settings?.cpuQuietThresholdMs,
|
|
151
|
-
blankPage: config.settings?.blankPage,
|
|
152
|
-
}],
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
134
|
/**
|
|
157
135
|
* Run Lighthouse in the selected runner.
|
|
158
136
|
* @param {Smokehouse.TestDfn} smokeTestDefn
|
|
159
|
-
* @param {{isDebug?: boolean,
|
|
137
|
+
* @param {{isDebug?: boolean, retries: number, lighthouseRunner: Smokehouse.LighthouseRunner, takeNetworkRequestUrls?: () => string[]}} testOptions
|
|
160
138
|
* @return {Promise<SmokehouseResult>}
|
|
161
139
|
*/
|
|
162
140
|
async function runSmokeTest(smokeTestDefn, testOptions) {
|
|
163
|
-
const {id, expectations} = smokeTestDefn;
|
|
141
|
+
const {id, expectations, config} = smokeTestDefn;
|
|
164
142
|
const {
|
|
165
143
|
lighthouseRunner,
|
|
166
144
|
retries,
|
|
167
145
|
isDebug,
|
|
168
|
-
useLegacyNavigation,
|
|
169
146
|
takeNetworkRequestUrls,
|
|
170
147
|
} = testOptions;
|
|
171
148
|
const requestedUrl = expectations.lhr.requestedUrl;
|
|
@@ -184,15 +161,10 @@ async function runSmokeTest(smokeTestDefn, testOptions) {
|
|
|
184
161
|
bufferedConsole.log(` Retrying run (${i} out of ${retries} retries)…`);
|
|
185
162
|
}
|
|
186
163
|
|
|
187
|
-
let config = smokeTestDefn.config;
|
|
188
|
-
if (useLegacyNavigation) {
|
|
189
|
-
config = convertToLegacyConfig(config);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
164
|
// Run Lighthouse.
|
|
193
165
|
try {
|
|
194
166
|
result = {
|
|
195
|
-
...await lighthouseRunner(requestedUrl, config, {isDebug
|
|
167
|
+
...await lighthouseRunner(requestedUrl, config, {isDebug}),
|
|
196
168
|
networkRequests: takeNetworkRequestUrls ? takeNetworkRequestUrls() : undefined,
|
|
197
169
|
};
|
|
198
170
|
|
|
@@ -213,7 +185,6 @@ async function runSmokeTest(smokeTestDefn, testOptions) {
|
|
|
213
185
|
report = getAssertionReport(result, expectations, {
|
|
214
186
|
runner: lighthouseRunner.runnerName,
|
|
215
187
|
isDebug,
|
|
216
|
-
useLegacyNavigation,
|
|
217
188
|
});
|
|
218
189
|
|
|
219
190
|
runs.push({
|
package/package.json
CHANGED
|
@@ -53,13 +53,11 @@ declare global {
|
|
|
53
53
|
{expectations: Smokehouse.ExpectedRunnerResult | Array<Smokehouse.ExpectedRunnerResult>}
|
|
54
54
|
|
|
55
55
|
export type LighthouseRunner =
|
|
56
|
-
{runnerName?: string} & ((url: string, config?: Config, runnerOptions?: {isDebug?: boolean
|
|
56
|
+
{runnerName?: string} & ((url: string, config?: Config, runnerOptions?: {isDebug?: boolean}) => Promise<{lhr: LHResult, artifacts: Artifacts, log: string}>);
|
|
57
57
|
|
|
58
58
|
export interface SmokehouseOptions {
|
|
59
59
|
/** If true, performs extra logging from the test runs. */
|
|
60
60
|
isDebug?: boolean;
|
|
61
|
-
/** If true, use the legacy navigation runner. */
|
|
62
|
-
useLegacyNavigation?: boolean;
|
|
63
61
|
/** Manually set the number of jobs to run at once. `1` runs all tests serially. */
|
|
64
62
|
jobs?: number;
|
|
65
63
|
/** The number of times to retry failing tests before accepting. Defaults to 0. */
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export default FirstContentfulPaint3G;
|
|
2
|
-
declare class FirstContentfulPaint3G extends Audit {
|
|
3
|
-
/**
|
|
4
|
-
* @return {LH.Audit.ScoreOptions}
|
|
5
|
-
*/
|
|
6
|
-
static get defaultOptions(): import("../../../types/audit.js").default.ScoreOptions;
|
|
7
|
-
/**
|
|
8
|
-
* @param {LH.Artifacts} artifacts
|
|
9
|
-
* @param {LH.Audit.Context} context
|
|
10
|
-
* @return {Promise<LH.Audit.Product>}
|
|
11
|
-
*/
|
|
12
|
-
static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
|
|
13
|
-
}
|
|
14
|
-
import { Audit } from '../audit.js';
|
|
15
|
-
//# sourceMappingURL=first-contentful-paint-3g.d.ts.map
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright 2019 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
4
|
-
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {Audit} from '../audit.js';
|
|
8
|
-
import {FirstContentfulPaint as ComputedFcp} from '../../computed/metrics/first-contentful-paint.js';
|
|
9
|
-
import * as constants from '../../config/constants.js';
|
|
10
|
-
|
|
11
|
-
const regular3G = constants.throttling.mobileRegular3G;
|
|
12
|
-
|
|
13
|
-
class FirstContentfulPaint3G extends Audit {
|
|
14
|
-
/**
|
|
15
|
-
* @return {LH.Audit.Meta}
|
|
16
|
-
*/
|
|
17
|
-
static get meta() {
|
|
18
|
-
return {
|
|
19
|
-
id: 'first-contentful-paint-3g',
|
|
20
|
-
title: 'First Contentful Paint (3G)',
|
|
21
|
-
description: 'First Contentful Paint 3G marks the time at which the first text or image is ' +
|
|
22
|
-
'painted while on a 3G network. ' +
|
|
23
|
-
'[Learn more about the First Contentful Paint (3G) metric](https://developers.google.com/web/tools/lighthouse/audits/first-contentful-paint).',
|
|
24
|
-
scoreDisplayMode: Audit.SCORING_MODES.NUMERIC,
|
|
25
|
-
supportedModes: ['navigation'],
|
|
26
|
-
requiredArtifacts: ['traces', 'devtoolsLogs', 'GatherContext', 'URL'],
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @return {LH.Audit.ScoreOptions}
|
|
32
|
-
*/
|
|
33
|
-
static get defaultOptions() {
|
|
34
|
-
return {
|
|
35
|
-
// 25th and 8th percentiles HTTPArchive on Slow 4G -> multiply by 1.5 for RTT differential -> median and p10.
|
|
36
|
-
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2021_05_01_mobile
|
|
37
|
-
// https://www.desmos.com/calculator/xi5oympawp
|
|
38
|
-
p10: 2700,
|
|
39
|
-
median: 4500,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @param {LH.Artifacts} artifacts
|
|
45
|
-
* @param {LH.Audit.Context} context
|
|
46
|
-
* @return {Promise<LH.Audit.Product>}
|
|
47
|
-
*/
|
|
48
|
-
static async audit(artifacts, context) {
|
|
49
|
-
const gatherContext = artifacts.GatherContext;
|
|
50
|
-
const trace = artifacts.traces[Audit.DEFAULT_PASS];
|
|
51
|
-
const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
|
|
52
|
-
/** @type {LH.Audit.Context['settings']} */
|
|
53
|
-
const settings = {...context.settings, throttlingMethod: 'simulate', throttling: regular3G};
|
|
54
|
-
const metricComputationData = {trace, devtoolsLog, gatherContext, settings, URL: artifacts.URL};
|
|
55
|
-
const metricResult = await ComputedFcp.request(metricComputationData, context);
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
score: Audit.computeLogNormalScore(
|
|
59
|
-
{p10: context.options.p10, median: context.options.median},
|
|
60
|
-
metricResult.timing
|
|
61
|
-
),
|
|
62
|
-
numericValue: metricResult.timing,
|
|
63
|
-
numericUnit: 'millisecond',
|
|
64
|
-
displayValue: `${metricResult.timing}\xa0ms`,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export default FirstContentfulPaint3G;
|