Cannot read property 'watch' of undefined
See original GitHub issue🐛 Bug Report
On an ejected Create-react-app project, I installed puppeteer
and jest-puppeteer
and ran a simple script to run jest, but it’s immediately returning
TypeError: Cannot read property 'watch' of undefined
at setup (/node_modules/jest-environment-puppeteer/lib/global.js:30:18)
My jest config is inside my package.json
file so I added it in there as mentioned in docs:
"jest": {
"preset": "jest-puppeteer"
}
I ran two jest commands below, but still get the same result above:
"test": "node ./scripts/test.js --env=jsdom"
"test": "jest"
Jest Configuration
"jest": "^22.4.2"
"jest-puppeteer": "^3.9.0"
"puppeteer": "^1.12.0"
Expected behavior
I was hoping the test would run successfully without any internal errors.
Run npx envinfo --system --binaries --npmPackages expect-puppeteer,jest-dev-server,jest-environment-puppeteer,jest-puppeteer,spawnd --markdown --clipboard
Paste the results here:
## System:
- OS: macOS 10.14.2
- CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
- Memory: 676.66 MB / 16.00 GB
- Shell: 3.2.57 - /bin/bash
## Binaries:
- Node: 8.9.4 - ~/.nvm/versions/node/v8.9.4/bin/node
- Yarn: 1.13.0 - /usr/local/bin/yarn
- npm: 5.6.0 - ~/.nvm/versions/node/v8.9.4/bin/npm
- Watchman: 4.9.0 - /usr/local/bin/watchman
## npmPackages:
- jest-puppeteer: ^3.9.0 => 3.9.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Cannot read property 'watch' of undefined in gulp
When I trigger the command gulp watch in the cmd, I receive the following error TypeError: Cannot read property 'watch' of undefined.
Read more >Can Not Read Properties of Undefined Reading Map in React ...
If you are looking at can not read properties of undefined reading map in react js error or map function is not displaying...
Read more >Fix "Cannot read properties of undefined" error #shorts
Sometimes in Javascript you might have an array of objects like this and you to need to get some of the properties of...
Read more >Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >Cannot read properties of undefined (reading 'length') - TrackJS
This error can be thrown for a lot of reasons, as it is incredibly common to reference the length property of string or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@binhxn @petekp
It seems that in the jest v22 version we can’t get
jestConfig
injestSetup
, we will be compatible as soon as possibleNow, you can choose to use jest v23.6 to solve this bug.
Using Jest 23.6 works, thank you.