-
Notifications
You must be signed in to change notification settings - Fork 288
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
How to emulate devices with jest and puppeteer #510
Comments
Hello @bitstarr, I think you are looking for |
@gregberge you may have noticed that I already consulted this page (see last code block) but it does not provide a solution. |
The emulate function is calling setUserAgent and setViewport internally. It seems that both are not implemented and just throw an error. I think pr is this. Appears to be a response to webdriver-bidi. playwright can use chrome. So we may be able to do it by copying playwright's implementation Postscript I solved the problem here. // jest-puppeteer.config.js
module.exports = {
exitOnPageError: false,
}; When I commented out page.emulate(), the test succeeded, so I thought page.emulate() was the cause. But it seems there was another cause. |
Since
puppeteer.devices()
got removed with puppeteer 19.1.0, there are no blog posts or other helping sources on how to emulate a certain device with a jest and puppeteer setup.I'm not a JS or node expert, I'm new to jest and puppeteer, but I need to test my frontend.
So I got the following jest test:
these node packages are relevant, I guess:
Does anyone have an idea how the code from the puppeteer docs
will transform to work with jest?
The text was updated successfully, but these errors were encountered: