GoogleChrome / web-vitals

Essential metrics for a healthy site.
https://web.dev/vitals
Apache License 2.0
7.59k stars 415 forks source link

page.evaluate: ReferenceError: _webVitals is not defined in Playwright #336

Closed MehseinJohan closed 1 year ago

MehseinJohan commented 1 year ago

Hello team,

I've installed the framework in my playwright regression. Though, when trying to play my script :

test('screenshot_testing', async ({ cWelcomePage, page, webActions, baseURL, browserName }) => {
//Display Home page
await WelcomePage.isPageSuccessfullyDisplayed()
  page.evaluate(() => onCLS(console.log))
});

I get rejected with -:

page.evaluate: ReferenceError: _webVitals is not defined
    at eval (eval at evaluate (:197:30), <anonymous>:1:22)
    at UtilityScript.evaluate (<anonymous>:199:17)
    at UtilityScript.<anonymous> (<anonymous>:1:44)
    at tests\regression_testing\platform\homepage\page-display.ts:22:8

Could you please help ?

Thank you in advance,

Regards,

Johan

tunetheweb commented 1 year ago

I'm afraid I don't know Playwright so can't comment on the code. A previous issue showed some code that might be helpful: #180