Closed theGABS closed 5 years ago
Just meet the same issue. I read this note from the document.
NOTE: Be sure to remove any existing
testEnvironment
option from your Jest configuration. Thejest-puppeteer
preset needs to manage that option itself.
After removing testEnvironment
in my config file, this error doesn't present anymore.
Hope this well help.
Didn't help me at all. Problem persists
Putting
/**
* @jest-environment puppeteer
*/
above all imports in my test files fixed the issue
this last comment needs to be included in the documentation!
@raptoria PRs are welcome 😁👍
My comment works but this is even better
"web:test": "react-app-rewired test --env=puppeteer",
I included these comments in a PR: https://github.com/smooth-code/jest-puppeteer/pull/416
I included these comments in a PR: #416
I'm not sure that what's been described in the comments so far really addresses the root issue. or at least, they can't be the complete picture, because this repo demonstrates the original complaint, even while adopting all of the proposed solutions:
https://github.com/nweajoseph/jest-puppetteer-bug-report
no "testEnvironment" is manually set in jest.config.js
, the /** * @jest-environment puppeteer */
comment solution errors:
● Test suite failed to run
wsEndpoint not found
at PuppeteerEnvironment.setup (node_modules/jest-environment-puppeteer/lib/PuppeteerEnvironment.js:45:13)
and otherwise the test and config are verbatim from the existing "how to setup" docs:
npx create-react-app . --template= typescript
npm install --save-dev jest-puppeteer puppeteer jest
npm install --save-dev @types/puppeteer @types/jest-environment-puppeteer @types/expect-puppeteer
# configure jest.config.json and delete any files unnecessary to reproduce the issue
npm test
If you put the --env=puppeteer
in your "scripts" {
"test": "......what it was before --env=puppeteer"
}
It should work
But why is --env=puppeteer
needed? Should jest-puppeteer be setting the test environment? What is overriding jest-puppeteer?
In my case it was cool to run jest test with puppeteer with an env because I use Detox to test Android/iOS with other Jest runner and use a web abstraction for Detox with puppeteer.
E.g. you could provide custom jest config to only run .e2e.js files + puppeteer and the rest are just 'normal' tests running with the normal Jest runner
PS: you have a such nice homepage I'm looking at it right now
It looks like this has nothing to do with typescript but with react-scripts
overriding the testEnvironment
to 'jsdom'
if --env
isn't provided.
🐛 Bug Report
I cannot setup code to use your preset with typescript and CRA
To Reproduce
jest.config.js
package.json
App.test.tsx
when I run
npm t
I get errorExpected behavior
Run without error / page is defined
Link to repl or repo (highly encouraged)
Sorry, it is private work, cannot share :(
Run
npx envinfo --system --binaries --npmPackages expect-puppeteer,jest-dev-server,jest-environment-puppeteer,jest-puppeteer,spawnd --markdown --clipboard
Paste the results here: