I just tried adding jest-puppeteer to an existing project and I was getting page is undefined when running my tests, even though the preset: 'jest-puppeteer' was set and Jest was launching without any errors.
After a while I tried upgrading Jest from 21 to 22, and it solved the problem. So it seems jest-puppeteer peer-depends on jest >= 22. If so, it would be good to mention this in the readme and/or officially add it to peerDependencies.
Thanks for making this great project btw!
Thanks for spotting it, I prefer to not add Jest in peer dependencies. Jest 22 has been released 5 months ago. I think we don't have to mention it. Your issue will be the answer.
I'm not sure if 5 months is a long time at all. I'm sure a lot of slow-moving corporate codebases are still on Jest 21 or older. Would it be a problem to add the words "Requires Jest 22 or higher" in the readme (maybe in the same blockquote that recommends additional typescript-related packages)? That would have saved me a few hours yesterday.
You are right, done!
@callumlocke Can you please share the configuration that you made to work jest with puppetter ?
I've setup my environment according to the documentation available here: https://jestjs.io/docs/en/puppeteer but faced the problem.
After trying some things I discovered that actually, nowadays, the right way to setup is to use jest-environment-puppeteer as described here:
https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer
and created a PR https://github.com/facebook/jest/pull/8882
For me, a standard jest-puppeteer is working fine.
In case, when somebody still have this issue, here is a general advice.
Verify, whether a configuration file jest.config.js (or whatever name) is actually get's executed. Just make intentionaly some syntax error in this file and take look at the console output, when staring jest.
So, if everything looks, like config file is not get's executed, check, whether it's name is passed in starting command, like this:
jest integration --config=jest.config.js
I fixed that by reading again the DOC
NOTE: Be sure to remove any existing testEnvironment option from your Jest configuration. The jest-puppeteer preset needs to manage that option itself.
Most helpful comment
I fixed that by reading again the DOC