LHCI version: 0.3.14
LHCI fails to run puppeteer script for authentication. Fails with error Unable to require 'puppeteer' for script, have you run 'npm i puppeteer'?.
Puppeteer is installed and made available using
Error
~/S/r/lighthouse ❯❯❯ lhci autorun
✅ .lighthouseci/ directory writable
✅ Configuration file found
✅ Chrome installation found
✅ Ancestor hash determinable
✅ LHCI server reachable
✅ LHCI server API-compatible
✅ LHCI server token valid
⚠️ LHCI server non-unique build for this hash
Healthcheck passed!
Error: Unable to require 'puppeteer' for script, have you run 'npm i puppeteer'?
at PuppeteerManager._getBrowser (/usr/local/lib/node_modules/@lhci/cli/src/collect/puppeteer-manager.js:48:13)
at PuppeteerManager.invokePuppeteerScriptForUrl (/usr/local/lib/node_modules/@lhci/cli/src/collect/puppeteer-manager.js:96:32)
at Object.runCommand (/usr/local/lib/node_modules/@lhci/cli/src/collect/collect.js:189:23)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async run (/usr/local/lib/node_modules/@lhci/cli/src/cli.js:85:7)
lighthouserc.js
const AUT_BASE_URL = process.AUT_BASE_URL
const LIGHTHOUSE_SERVER_TOKEN = process.env.LIGHTHOUSE_SERVER_TOKEN
const LIGHTHOUSE_SERVER_URL = process.env.LIGHTHOUSE_SERVER_URL
module.exports = {
ci: {
collect: {
"url": [
`${AUT_BASE_URL}`
],
"puppeteerScript": "login-script.js",
"puppeteerLaunchOptions": {defaultViewport: null, args:["--disable-gpu --window-size=1920,1080", "--no-sandbox"], headless: true},
"headful": false,
"isSinglePageApplication": true,
"disableStorageReset": true,
"settings": {
"output": "json",
"maxWaitForFcp": 30000,
"maxWaitForLoad": 45000,
"throttlingMethod": "simulate",
"auditMode": false,
"gatherMode": false,
"disableStorageReset": true,
"emulatedFormFactor": "desktop",
"internalDisableDeviceScreenEmulation": true,
"channel": "devtools",
"budgets": null,
"locale": "en-US",
"blockedUrlPatterns": null,
"additionalTraceCategories": null,
"extraHeaders": null,
"precomputedLanternData": null,
"onlyAudits": null,
"onlyCategories": [
"performance",
"pwa",
"best-practices",
"accessibility",
],
"skipAudits": null
}
},
upload: {
"target": "lhci",
"token": LIGHTHOUSE_SERVER_TOKEN,
"serverBaseUrl": LIGHTHOUSE_SERVER_URL
},
},
};
login-script.js
/**
* @param {puppeteer.Browser} browser
* @param {{url: string, options: LHCI.CollectCommand.Options}} context
*/
const USER = process.env.USER
const PASSWORD = process.env.PASSWORD
const URL = process.env.URL
module.exports = async (browser, {url}) => {
const page = await browser.newPage();
await page.setViewport({ width: 1920, height: 1080 });
await page.goto(context.url);
await page.waitForSelector(locators.inputEmailInput, { visible: true });
// Fill in and submit login form.
const emailInput = await page.$(locators.inputEmailInput);
await emailInput.type(USER);
const passwordInput = await page.$(locators.inputEmailPassword);
await passwordInput.type(PASSWORD);
await Promise.all([
page.$eval(locators.btnLogin, btn => btn.click()),
page.waitForNavigation({ waitUntil: "networkidle2" })
]).catch(function(err) {
console.log("Login Failed")
process.exit(1)
});
await page.close();
};
LHCI version: 0.3.14
LHCI fails to run puppeteer script for authentication. Fails with error
Unable to require 'puppeteer' for script, have you run 'npm i puppeteer'?.Puppeteer is installed and made available using
Error
lighthouserc.js
login-script.js