question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:

  1. "test": "node ./scripts/test.js --env=jsdom"
  2. "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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
xiaoyuhencommented, Feb 8, 2019

@binhxn @petekp

It seems that in the jest v22 version we can’t get jestConfig in jestSetup, we will be compatible as soon as possible

Now, you can choose to use jest v23.6 to solve this bug.

0reactions
binhxncommented, Feb 10, 2019

Using Jest 23.6 works, thank you.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found