GoogleChrome / lighthouse-ci

Automate running Lighthouse for every commit, viewing the changes, and preventing regressions
Apache License 2.0
6.41k stars 643 forks source link

Unable to get user data directory working together with puppeteer script #1012

Open ghost opened 7 months ago

ghost commented 7 months ago

Using "lhci autorun" in Azure Devops pipeline against authenticated site using a lighthouserc.json for configuration and a puppeteer script that successfully logs in to my site. In the puppeteer script I have set a specific userDataDir that is successfully created, called "puppDataDir". But I am unable to get the following lighthouse process to use that user directory. Instead I'm being redirected to my login page and that is analyzed instead.

If I use a script for the entire process, hence puppeteering into the page and then using lighthouse programmatically, then the analysis is run correctly, but I want to be able to upload to CI server, and this is so smooth using the autorun.

So, is it a bug or me doing something wrong or is this not even a supported use case?

Expected behavior Running lhci autorun with a selected user-data-dir should pick up the authenticated session from puppeteer.

My json config looks like this, but note that I have also tried setting chromeFlags user-data-dir, but then getting warning that it is not used when having puppeteerScript set.: { "ci": { "collect": { "puppeteerScript": "./lh-runner.js", "puppeteerLaunchOptions": { "args": [ "'--user-data-dir=puppDataDir'" ] }, "chromePath": false, "numberOfRuns": 1, "disableStorageReset": true, "url": [ "XXX" ], "ignoreDuplicateBuildFailure": true, "emulatedFormFactor": "desktop", "screenEmulation": "desktop", "emulatedUserAgent": "desktop", "output": [ "html" ] }, "upload": { "target": "lhci", "serverBaseUrl": "XXXX", "token": "XXXXX", "ignoreDuplicateBuildFailure": true } } }