abhinaba-ghosh / playwright-lighthouse

:performing_arts:: Playwright Lighthouse Audit
https://www.npmjs.com/package/playwright-lighthouse
MIT License
250 stars 28 forks source link

playAudit with route.fulfill #20

Closed toadornode closed 3 years ago

toadornode commented 3 years ago

I'm currently using the route.fulfill function from playwright to mock the response to our API in our UI application. In the same test case where I call route.fulfill, I call playAudit function.

When the first page.goto() loads, it loads the page correctly with the mocked response. But when playAudit spawns a new browser to run the lighthouse metrics, it completely forgets about the route.fulfill.

I've tried using the persistent context function but we're not storing anything in local storage so I don't think that will work here...

Is there any way to mock api calls when using playAudit?

toadornode commented 3 years ago

Nevermind, I was able to get it working with this code example Running lighthouse on authenticated routes with the test runner

https://npm.io/package/playwright-lighthouse

Thank you so much for this code example. This is awesome :)