-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: update docs for v3 #5357
docs: update docs for v3 #5357
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,6 @@ Tracing processor takes the output of trace of tab and identifies the top-level | |
|
||
## Audits | ||
|
||
The return value of each audit [takes this shape](https://github.com/GoogleChrome/lighthouse/blob/b354890076f2c077c5460b2fa56ded546cca72ee/lighthouse-core/closure/typedefs/AuditResult.js#L23-L55). | ||
The return value of each audit [takes this shape](https://github.com/GoogleChrome/lighthouse/blob/8f500e00243e07ef0a80b39334bedcc8ddc8d3d0/typings/audit.d.ts#L117-L130). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice catch, didn't even think to search for these.... :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hi |
||
|
||
The `details` object is parsed in report-renderer.js. View other audits for guidance on how to structure `details`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,11 @@ function launchChromeAndRunLighthouse(url, opts, config = null) { | |
return chromeLauncher.launch({chromeFlags: opts.chromeFlags}).then(chrome => { | ||
opts.port = chrome.port; | ||
return lighthouse(url, opts, config).then(results => { | ||
// The gathered artifacts are typically removed as they can be quite large (~50MB+) | ||
delete results.artifacts; | ||
return chrome.kill().then(() => results) | ||
// use results.lhr for the JS-consumeable output | ||
// https://github.com/GoogleChrome/lighthouse/blob/master/typings/lhr.d.ts | ||
// use results.report for the HTML/JSON/CSV output as a string | ||
// use results.artifacts for the trace/screenshots/other specific case you need (rarer) | ||
return chrome.kill().then(() => results.lhr) | ||
}); | ||
}); | ||
} | ||
|
@@ -39,13 +41,31 @@ Many modules consuming Lighthouse are only interested in the performance numbers | |
You can limit the audits you run to a particular category or set of audits. | ||
|
||
```js | ||
const perfConfig = require('lighthouse/lighthouse-core/config/perf-config.js'); | ||
// ... | ||
launchChromeAndRunLighthouse(url, flags, perfConfig).then( // ... | ||
const flags = {onlyCategories: ['performance']}; | ||
launchChromeAndRunLighthouse(url, flags).then( // ... | ||
``` | ||
|
||
You can also craft your own config (e.g. [mixed-content-config.js](https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/config/mixed-content-config.js)) for custom runs. Also see the [basic custom audit recipe](https://github.com/GoogleChrome/lighthouse/tree/master/docs/recipes/custom-audit). | ||
|
||
### Differences from CLI flags | ||
|
||
Note that some flag functionality is only available to the CLI. The set of shared flags that work in both node and CLI can be found [in our typedefs](https://github.com/GoogleChrome/lighthouse/blob/8f500e00243e07ef0a80b39334bedcc8ddc8d3d0/typings/externs.d.ts#L68). In most cases, the functionality is not offered in the node module simply because it is easier and more flexible to do it yourself. | ||
|
||
| CLI Flag | Differences in Node | | ||
| - | - | | ||
| `port` | Only specifies which port to use, Chrome is not launched for you. | | ||
| `chromeFlags` | Ignored, Chrome is not launched for you. | | ||
| `outputPath` | Ignored, output is returned as string in `.report` property. | | ||
| `saveAssets` | Ignored, artifacts are returned in `.artifacts` property. | | ||
| `view` | Ignored, use the `opn` npm module if you want this functionality. | | ||
| `enableErrorReporting` | Ignored, error reporting is always disabled for node. | | ||
| `listAllAudits` | Ignored, not relevant in programmatic use. | | ||
| `listTraceCategories` | Ignored, not relevant in programmatic use. | | ||
| `configPath` | Ignored, pass the config in as the 3rd argument to `lighthouse`. | | ||
| `preset` | Ignored, pass the config in as the 3rd argument to `lighthouse`. | | ||
| `verbose` | Ignored, use `logLevel` instead. | | ||
| `quiet` | Ignored, use `logLevel` instead. | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a great new section |
||
|
||
### Turn on logging | ||
|
||
|
@@ -56,7 +76,7 @@ the `logLevel` flag when calling `lighthouse`. | |
```javascript | ||
const log = require('lighthouse-logger'); | ||
|
||
const flags = {logLevel: 'info', output: 'json'}; | ||
const flags = {logLevel: 'info'}; | ||
log.setLevel(flags.logLevel); | ||
|
||
launchChromeAndRunLighthouse('https://example.com', flags).then(...); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.