Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
;(async () => {
try {
sinon.stub(psi, 'runPsi').returns(Promise.resolve(data))
await runLighthouse(
'https://www.bbc.com/news',
{
output: ['html'],
outputPath: './results/bbc.com.html',
view: true,
plugins: ['lighthouse-plugin-field-performance'],
chromeFlags: '--headless'
},
config
)
process.exit(0)
} catch (e) {
console.log(e)
process.exit(1)
}
})()
serial('Measure field perf for site in CruX', async t => {
const resName = 'in-field.json'
await runLighthouse('https://example.com/', { ...lhOptions, outputPath: `./results/${resName}` })
const { audits, categories } = getTestResults(resName)
checkResponse(audits['field-fcp'])
checkResponse(audits['field-fid'])
checkResponse(audits['field-fcp-origin'])
checkResponse(audits['field-fid-origin'])
t.snapshot(categories['lighthouse-plugin-field-performance'])
/** @param {object} audit */
function checkResponse(audit) {
t.snapshot(omit(audit, ['details', 'displayValue', 'numericValue', 'score']))
t.true(isNumber(audit.score) && audit.score > 0 && audit.score < 1)
t.true(isNumber(audit.numericValue))
t.true(isString(audit.displayValue))
t.snapshot({
...audit.details,
serial('Measure field perf for site site not in CruX', async t => {
const resName = 'not-in-field.json'
await runLighthouse('https://alekseykulikov.com/', { ...lhOptions, outputPath: `./results/${resName}` })
const { audits, categories } = getTestResults(resName)
t.snapshot(audits['field-fcp'])
t.snapshot(audits['field-fid'])
t.snapshot(audits['field-fcp-origin'])
t.snapshot(audits['field-fid-origin'])
t.snapshot(categories['lighthouse-plugin-field-performance'])
})
const { runLighthouse } = require('lighthouse/lighthouse-cli/run')
const lhOptions = {
output: ['json'],
outputPath: './results/test-results.json',
chromeFlags: '--headless --enable-logging --no-sandbox',
plugins: ['lighthouse-plugin-greenhouse']
}
runLighthouse('https://www.google.com', lhOptions).then(result => {
process.exit(0);
})