GoogleChrome / lighthouse

Automated auditing, performance metrics, and best practices for the web.
https://developer.chrome.com/docs/lighthouse/overview/
Apache License 2.0
28.27k stars 9.35k forks source link

Update puppeteer types to accept `puppeteer-core` from outside Lighthouse #16152

Open yasserhussien opened 1 month ago

yasserhussien commented 1 month ago

When I try to use Cypress/puppeteer plugin for lighthouse user flow it doesn't work for me The problem is that the function startFlow from lighthouse assume that he will receive the page from lighthouse/types/puppeteer but it received from puppeteer-core/lib/types. is there a way to solve this problem OR should we use puppeteer itself and there is no way to work with cypress?

adamraine commented 1 month ago

Lighthouse type checking will accept a page from the puppeteer package in your dependencies but not necessarily the puppeteer-core so that is likely the root of the issue. Is it just a type error, or are there any runtime errors?

yasserhussien commented 1 month ago

Hi @adamraine yes it is a type error

adamraine commented 1 month ago

It might be possible, but would possibly be a breaking change. Right now Lighthouse accepts puppeteer page's from two locations:

  1. The puppeteer-core package in LIghthouse's package dependencies
  2. The first puppeteer package we find in node_modules

We would need to expand this list:

  1. The puppeteer-core package in LIghthouse's package dependencies
  2. The first puppeteer package we find in node_modules
  3. The first puppeteer-core package we find node_modules

1 & 3 overlap so I think we might need to give an alias to the package in Lighthouse's deps? I think for now it's easiest to just @ts-expect-error this one but we can track the upgrade here.