TypeError: TestEnvironment is not a constructor in combination with Enzyme
See original GitHub issueWith Enzyme installed, running tests:
"test": "react-scripts test --env=jsdom"
Throws the error:
TypeError: TestEnvironment is not a constructor
at runTest (node_modules/react-scripts/node_modules/jest/node_modules/jest-cli/build/runTest.js:30:15)
The tests run correctly when removing --env=jsdom
.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Cannot create custom TestEnvironment in Jest - Stack Overflow
I am trying to create a custom test environment with Jest as described in their official ... TypeError: TestEnvironment is not a constructor...
Read more >Doc TypeError in Jest test environment - Yjs Community
Hello everyone, I am trying to test yjs with Jest. Unfortunately I was not able to get an initial test running because of...
Read more >Configuring Jest
If a given module's path matches any of the patterns, it will not be require() -able in the test environment. These pattern strings...
Read more >jest-environment-jsdom | Yarn - Package Manager
Jest uses verbose mode when running a single test file. Console messages are now buffered and printed along with the test results. Fix...
Read more >Setup - Testing Library
React Testing Library does not require any configuration to be used. However, ... querySelector or a combination of existing
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
We’re going to cut a patch fixing this today but for now, you can work around it by opening
node_modules/react-scripts/node_modules/jest-config/build/normalize.js
and commenting out lines 80 to 90.I fixed this locally by commenting these lines out. In case of Create React App it is incorrect to resolve relative to
rootDir
because that’s not where Jest is. It should tryrequire.resolve()
first—at least for our use case.