lighthouse 9.5.0-dev.20220706 → 9.5.0-dev.20220709
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/.gitattributes +2 -1
- package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +3 -3
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js +7 -7
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +3 -19
- package/lighthouse-cli/test/smokehouse/report-assert.js +5 -5
- package/lighthouse-cli/test/smokehouse/smokehouse.js +38 -7
- package/lighthouse-core/gather/driver.js +1 -1
- package/lighthouse-core/lib/lantern-trace-saver.js +1 -1
- package/lighthouse-core/scripts/download-chrome.sh +1 -1
- package/package.json +1 -1
- package/readme.md +0 -1
- package/types/smokehouse.d.ts +3 -3
package/.gitattributes
CHANGED
|
@@ -135,10 +135,10 @@ async function begin() {
|
|
|
135
135
|
default: false,
|
|
136
136
|
describe: 'Save test artifacts and output verbose logs',
|
|
137
137
|
},
|
|
138
|
-
'
|
|
138
|
+
'legacy-navigation': {
|
|
139
139
|
type: 'boolean',
|
|
140
140
|
default: false,
|
|
141
|
-
describe: 'Use the
|
|
141
|
+
describe: 'Use the legacy navigation runner',
|
|
142
142
|
},
|
|
143
143
|
'jobs': {
|
|
144
144
|
type: 'number',
|
|
@@ -216,7 +216,7 @@ async function begin() {
|
|
|
216
216
|
jobs,
|
|
217
217
|
retries,
|
|
218
218
|
isDebug: argv.debug,
|
|
219
|
-
|
|
219
|
+
useLegacyNavigation: argv.legacyNavigation,
|
|
220
220
|
lighthouseRunner: runLighthouse,
|
|
221
221
|
takeNetworkRequestUrls,
|
|
222
222
|
};
|
|
@@ -47,7 +47,7 @@ if (!isMainThread && parentPort) {
|
|
|
47
47
|
/**
|
|
48
48
|
* @param {string} url
|
|
49
49
|
* @param {LH.Config.Json|undefined} configJson
|
|
50
|
-
* @param {{isDebug?: boolean,
|
|
50
|
+
* @param {{isDebug?: boolean, useLegacyNavigation?: boolean}} testRunnerOptions
|
|
51
51
|
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts}>}
|
|
52
52
|
*/
|
|
53
53
|
async function runBundledLighthouse(url, configJson, testRunnerOptions) {
|
|
@@ -80,15 +80,15 @@ async function runBundledLighthouse(url, configJson, testRunnerOptions) {
|
|
|
80
80
|
try {
|
|
81
81
|
const logLevel = testRunnerOptions.isDebug ? 'info' : undefined;
|
|
82
82
|
let runnerResult;
|
|
83
|
-
if (testRunnerOptions.
|
|
83
|
+
if (testRunnerOptions.useLegacyNavigation) {
|
|
84
|
+
const connection = new ChromeProtocol(port);
|
|
85
|
+
runnerResult =
|
|
86
|
+
await lighthouse.legacyNavigation(url, {port, logLevel}, configJson, connection);
|
|
87
|
+
} else {
|
|
84
88
|
// Puppeteer is not included in the bundle, we must create the page here.
|
|
85
89
|
const browser = await puppeteer.connect({browserURL: `http://localhost:${port}`});
|
|
86
90
|
const page = await browser.newPage();
|
|
87
91
|
runnerResult = await lighthouse(url, {port, logLevel}, configJson, page);
|
|
88
|
-
} else {
|
|
89
|
-
const connection = new ChromeProtocol(port);
|
|
90
|
-
runnerResult =
|
|
91
|
-
await lighthouse.legacyNavigation(url, {port, logLevel}, configJson, connection);
|
|
92
92
|
}
|
|
93
93
|
if (!runnerResult) throw new Error('No runnerResult');
|
|
94
94
|
|
|
@@ -106,7 +106,7 @@ async function runBundledLighthouse(url, configJson, testRunnerOptions) {
|
|
|
106
106
|
* Launch Chrome and do a full Lighthouse run via the Lighthouse DevTools bundle.
|
|
107
107
|
* @param {string} url
|
|
108
108
|
* @param {LH.Config.Json=} configJson
|
|
109
|
-
* @param {{isDebug?: boolean,
|
|
109
|
+
* @param {{isDebug?: boolean, useLegacyNavigation?: boolean}=} testRunnerOptions
|
|
110
110
|
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts, log: string}>}
|
|
111
111
|
*/
|
|
112
112
|
async function runLighthouse(url, configJson, testRunnerOptions = {}) {
|
|
@@ -41,30 +41,16 @@ async function runLighthouse(url, configJson, testRunnerOptions = {}) {
|
|
|
41
41
|
.finally(() => !isDebug && fs.rm(tmpPath, {recursive: true, force: true}));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
/**
|
|
45
|
-
* @param {LH.Config.Json=} configJson
|
|
46
|
-
* @return {LH.Config.Json|undefined}
|
|
47
|
-
*/
|
|
48
|
-
function convertToFraggleRockConfig(configJson) {
|
|
49
|
-
if (!configJson) return configJson;
|
|
50
|
-
if (!configJson.passes) return configJson;
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
...configJson,
|
|
54
|
-
navigations: configJson.passes.map(pass => ({...pass, id: pass.passName})),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
44
|
/**
|
|
59
45
|
* Internal runner.
|
|
60
46
|
* @param {string} url
|
|
61
47
|
* @param {string} tmpPath
|
|
62
48
|
* @param {LH.Config.Json=} configJson
|
|
63
|
-
* @param {{isDebug?: boolean,
|
|
49
|
+
* @param {{isDebug?: boolean, useLegacyNavigation?: boolean}=} options
|
|
64
50
|
* @return {Promise<{lhr: LH.Result, artifacts: LH.Artifacts, log: string}>}
|
|
65
51
|
*/
|
|
66
52
|
async function internalRun(url, tmpPath, configJson, options) {
|
|
67
|
-
const {isDebug = false,
|
|
53
|
+
const {isDebug = false, useLegacyNavigation = false} = options || {};
|
|
68
54
|
const localConsole = new LocalConsole();
|
|
69
55
|
|
|
70
56
|
const outputPath = `${tmpPath}/smokehouse.report.json`;
|
|
@@ -81,9 +67,7 @@ async function internalRun(url, tmpPath, configJson, options) {
|
|
|
81
67
|
'--quiet',
|
|
82
68
|
];
|
|
83
69
|
|
|
84
|
-
if (
|
|
85
|
-
configJson = convertToFraggleRockConfig(configJson);
|
|
86
|
-
} else {
|
|
70
|
+
if (useLegacyNavigation) {
|
|
87
71
|
args.push('--legacy-navigation');
|
|
88
72
|
}
|
|
89
73
|
|
|
@@ -217,10 +217,10 @@ function makeComparison(name, actualResult, expectedResult) {
|
|
|
217
217
|
* @param {LocalConsole} localConsole
|
|
218
218
|
* @param {LH.Result} lhr
|
|
219
219
|
* @param {Smokehouse.ExpectedRunnerResult} expected
|
|
220
|
-
* @param {{runner?: string, isBundled?: boolean,
|
|
220
|
+
* @param {{runner?: string, isBundled?: boolean, useLegacyNavigation?: boolean}=} reportOptions
|
|
221
221
|
*/
|
|
222
222
|
function pruneExpectations(localConsole, lhr, expected, reportOptions) {
|
|
223
|
-
const
|
|
223
|
+
const isLegacyNavigation = reportOptions?.useLegacyNavigation;
|
|
224
224
|
const isBundled = reportOptions?.isBundled;
|
|
225
225
|
|
|
226
226
|
/**
|
|
@@ -276,13 +276,13 @@ function pruneExpectations(localConsole, lhr, expected, reportOptions) {
|
|
|
276
276
|
`Actual Chromium version: ${getChromeVersionString()}`,
|
|
277
277
|
].join(' '));
|
|
278
278
|
remove(key);
|
|
279
|
-
} else if (value._legacyOnly &&
|
|
279
|
+
} else if (value._legacyOnly && !isLegacyNavigation) {
|
|
280
280
|
localConsole.log([
|
|
281
281
|
`[${key}] marked legacy only but run is Fraggle Rock, pruning expectation:`,
|
|
282
282
|
JSON.stringify(value, null, 2),
|
|
283
283
|
].join(' '));
|
|
284
284
|
remove(key);
|
|
285
|
-
} else if (value._fraggleRockOnly &&
|
|
285
|
+
} else if (value._fraggleRockOnly && isLegacyNavigation) {
|
|
286
286
|
localConsole.log([
|
|
287
287
|
`[${key}] marked Fraggle Rock only but run is legacy, pruning expectation:`,
|
|
288
288
|
JSON.stringify(value, null, 2),
|
|
@@ -459,7 +459,7 @@ function reportAssertion(localConsole, assertion) {
|
|
|
459
459
|
* summary. Returns count of passed and failed tests.
|
|
460
460
|
* @param {{lhr: LH.Result, artifacts: LH.Artifacts, networkRequests?: string[]}} actual
|
|
461
461
|
* @param {Smokehouse.ExpectedRunnerResult} expected
|
|
462
|
-
* @param {{runner?: string, isDebug?: boolean, isBundled?: boolean,
|
|
462
|
+
* @param {{runner?: string, isDebug?: boolean, isBundled?: boolean, useLegacyNavigation?: boolean}=} reportOptions
|
|
463
463
|
* @return {{passed: number, failed: number, log: string}}
|
|
464
464
|
*/
|
|
465
465
|
function getAssertionReport(actual, expected, reportOptions = {}) {
|
|
@@ -53,7 +53,7 @@ const DEFAULT_RETRIES = 0;
|
|
|
53
53
|
async function runSmokehouse(smokeTestDefns, smokehouseOptions) {
|
|
54
54
|
const {
|
|
55
55
|
isDebug,
|
|
56
|
-
|
|
56
|
+
useLegacyNavigation,
|
|
57
57
|
jobs = DEFAULT_CONCURRENT_RUNS,
|
|
58
58
|
retries = DEFAULT_RETRIES,
|
|
59
59
|
lighthouseRunner = Object.assign(cliLighthouseRunner, {runnerName: 'cli'}),
|
|
@@ -65,7 +65,13 @@ async function runSmokehouse(smokeTestDefns, smokehouseOptions) {
|
|
|
65
65
|
// Run each testDefn in parallel based on the concurrencyLimit.
|
|
66
66
|
const concurrentMapper = new ConcurrentMapper();
|
|
67
67
|
|
|
68
|
-
const testOptions = {
|
|
68
|
+
const testOptions = {
|
|
69
|
+
isDebug,
|
|
70
|
+
useLegacyNavigation,
|
|
71
|
+
retries,
|
|
72
|
+
lighthouseRunner,
|
|
73
|
+
takeNetworkRequestUrls,
|
|
74
|
+
};
|
|
69
75
|
const smokePromises = smokeTestDefns.map(testDefn => {
|
|
70
76
|
// If defn is set to `runSerially`, we'll run it in succession with other tests, not parallel.
|
|
71
77
|
const concurrency = testDefn.runSerially ? 1 : jobs;
|
|
@@ -118,15 +124,35 @@ function purpleify(str) {
|
|
|
118
124
|
return `${log.purple}${str}${log.reset}`;
|
|
119
125
|
}
|
|
120
126
|
|
|
127
|
+
/**
|
|
128
|
+
* @param {LH.Config.Json=} configJson
|
|
129
|
+
* @return {LH.Config.Json|undefined}
|
|
130
|
+
*/
|
|
131
|
+
function convertToLegacyConfig(configJson) {
|
|
132
|
+
if (!configJson) return configJson;
|
|
133
|
+
if (!configJson.navigations) return configJson;
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
...configJson,
|
|
137
|
+
passes: configJson.navigations.map(nav => ({...nav, passName: nav.id.concat('Pass')})),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
121
141
|
/**
|
|
122
142
|
* Run Lighthouse in the selected runner.
|
|
123
143
|
* @param {Smokehouse.TestDfn} smokeTestDefn
|
|
124
|
-
* @param {{isDebug?: boolean,
|
|
144
|
+
* @param {{isDebug?: boolean, useLegacyNavigation?: boolean, retries: number, lighthouseRunner: Smokehouse.LighthouseRunner, takeNetworkRequestUrls?: () => string[]}} testOptions
|
|
125
145
|
* @return {Promise<SmokehouseResult>}
|
|
126
146
|
*/
|
|
127
147
|
async function runSmokeTest(smokeTestDefn, testOptions) {
|
|
128
|
-
const {id,
|
|
129
|
-
const {
|
|
148
|
+
const {id, expectations} = smokeTestDefn;
|
|
149
|
+
const {
|
|
150
|
+
lighthouseRunner,
|
|
151
|
+
retries,
|
|
152
|
+
isDebug,
|
|
153
|
+
useLegacyNavigation,
|
|
154
|
+
takeNetworkRequestUrls,
|
|
155
|
+
} = testOptions;
|
|
130
156
|
const requestedUrl = expectations.lhr.requestedUrl;
|
|
131
157
|
|
|
132
158
|
console.log(`${purpleify(id)} smoketest starting…`);
|
|
@@ -143,10 +169,15 @@ async function runSmokeTest(smokeTestDefn, testOptions) {
|
|
|
143
169
|
bufferedConsole.log(` Retrying run (${i} out of ${retries} retries)…`);
|
|
144
170
|
}
|
|
145
171
|
|
|
172
|
+
let configJson = smokeTestDefn.config;
|
|
173
|
+
if (useLegacyNavigation) {
|
|
174
|
+
configJson = convertToLegacyConfig(configJson);
|
|
175
|
+
}
|
|
176
|
+
|
|
146
177
|
// Run Lighthouse.
|
|
147
178
|
try {
|
|
148
179
|
result = {
|
|
149
|
-
...await lighthouseRunner(requestedUrl, configJson, {isDebug,
|
|
180
|
+
...await lighthouseRunner(requestedUrl, configJson, {isDebug, useLegacyNavigation}),
|
|
150
181
|
networkRequests: takeNetworkRequestUrls ? takeNetworkRequestUrls() : undefined,
|
|
151
182
|
};
|
|
152
183
|
} catch (e) {
|
|
@@ -161,7 +192,7 @@ async function runSmokeTest(smokeTestDefn, testOptions) {
|
|
|
161
192
|
report = getAssertionReport(result, expectations, {
|
|
162
193
|
runner: lighthouseRunner.runnerName,
|
|
163
194
|
isDebug,
|
|
164
|
-
|
|
195
|
+
useLegacyNavigation,
|
|
165
196
|
});
|
|
166
197
|
|
|
167
198
|
runs.push({
|
|
@@ -41,7 +41,7 @@ class Driver {
|
|
|
41
41
|
* @private
|
|
42
42
|
* Used to save network and lifecycle protocol traffic. Just Page and Network are needed.
|
|
43
43
|
*/
|
|
44
|
-
_devtoolsLog = new DevtoolsMessageLog(/^(Page|Network)\./);
|
|
44
|
+
_devtoolsLog = new DevtoolsMessageLog(/^(Page|Network|Target|Runtime)\./);
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* @private
|
|
@@ -154,7 +154,7 @@ function convertNodeTimingsToTrace(nodeTimings) {
|
|
|
154
154
|
...requestData,
|
|
155
155
|
decodedBodyLength: record.resourceSize,
|
|
156
156
|
didFail: !!record.failed,
|
|
157
|
-
finishTime: endTime,
|
|
157
|
+
finishTime: toMicroseconds(endTime) / (1000 * 1000),
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
/** @type {LH.TraceEvent[]} */
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -246,7 +246,6 @@ Useful documentation, examples, and recipes to get you started.
|
|
|
246
246
|
|
|
247
247
|
**Recipes**
|
|
248
248
|
|
|
249
|
-
- [gulp](docs/recipes/gulp) - helpful for CI integration
|
|
250
249
|
- [Plugin](./docs/recipes/lighthouse-plugin-example) - example Lighthouse plugin
|
|
251
250
|
- [Custom Audit example](./docs/recipes/custom-audit) - extend Lighthouse, run your own audits
|
|
252
251
|
|
package/types/smokehouse.d.ts
CHANGED
|
@@ -52,13 +52,13 @@ declare global {
|
|
|
52
52
|
{expectations: Smokehouse.ExpectedRunnerResult | Array<Smokehouse.ExpectedRunnerResult>}
|
|
53
53
|
|
|
54
54
|
export type LighthouseRunner =
|
|
55
|
-
{runnerName?: string} & ((url: string, configJson?: Config.Json, runnerOptions?: {isDebug?: boolean;
|
|
55
|
+
{runnerName?: string} & ((url: string, configJson?: Config.Json, runnerOptions?: {isDebug?: boolean; useLegacyNavigation?: boolean}) => Promise<{lhr: LHResult, artifacts: Artifacts, log: string}>);
|
|
56
56
|
|
|
57
57
|
export interface SmokehouseOptions {
|
|
58
58
|
/** If true, performs extra logging from the test runs. */
|
|
59
59
|
isDebug?: boolean;
|
|
60
|
-
/** If true,
|
|
61
|
-
|
|
60
|
+
/** If true, use the legacy navigation runner. */
|
|
61
|
+
useLegacyNavigation?: boolean;
|
|
62
62
|
/** Manually set the number of jobs to run at once. `1` runs all tests serially. */
|
|
63
63
|
jobs?: number;
|
|
64
64
|
/** The number of times to retry failing tests before accepting. Defaults to 0. */
|