Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update puppeteer dependency (v19) #498

Conversation

CarlosCortizasCT
Copy link

workerB

Summary

We wanted to update pupeeteer dependency in one of our projects where we also use jest-pupeeteer and we are finding unexpected errors in our tests, for instance when using toWatch matcher both in page and elements level.
Example:
image

It seems pupeeteer changed some APIs used from this package so directly updating does not work.
I tried to update the code where I found the problems but there still exist one test I'm not able to fix.
Perhaps others with more context in the project might know how.

Test plan

Currently, one of the tests is failing.

image

@@ -29,7 +29,7 @@ describe('not.toMatch', () => {
await expect(page).not.toMatch('home', options)
} catch (error) {
expect(error.message).toMatch('Text found "home"')
expect(error.message).toMatch('waiting for function failed')
expect(error.message).toMatch('Waiting failed')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pupeeteer now returns a different error message

@@ -3,10 +3,10 @@ export const getPuppeteerType = (instance) => {
instance &&
instance.constructor &&
instance.constructor.name &&
['Page', 'Frame', 'ElementHandle'].includes(instance.constructor.name) &&
['Page', 'CDPPage', 'Frame', 'ElementHandle'].includes(instance.constructor.name) &&
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pupeeteer now returns an instance of CDPPage class for page instances.

return {
page: await executionContext.frame(),
page: instance.frame,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way to access ElementHandle frame instance has changed as it was pointed here.

@UziTech
Copy link
Contributor

UziTech commented Oct 22, 2022

It looks like the test might be failing because of a bug in puppeteer v18.2 and up. puppeteer/puppeteer#1837 (comment)

@croesnick
Copy link

croesnick commented Nov 21, 2022

@CarlosCortizasCT Apparently the builds fail with

Cannot find module 'puppeteer-core/internal/common/Device.js' from '../node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js'

which may be due to "an issue" with jest-resolver, apparently caused by jest being too old. I tried upgrading jest to >= 28, but this caused another bag of problems with ESM vs CJS due to some changes in jest 28. I am quite new to the JS world, so my quick attempt to fix it failed. 🙈

But anyway: let me know if I can help here anyway or if you want to continue.

fyi: puppeteer < 18 should work in case you just want to upgrade "a bit".

@gregberge
Copy link
Member

Done.

@gregberge gregberge closed this Feb 3, 2023
@AnthonyPaulO
Copy link

AnthonyPaulO commented Apr 17, 2023

This is still an issue as far as the latest code base as of today. Is there a resolution to this? I'm getting the exact same issue, would love to know how to fix, don't understand why this is closed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants