TypeError: Cannot read properties of undefined (reading 'testEnvironmentOptions')
See original GitHub issueCurrent Behavior
Unable to use Jest to test React Native project inside an Nx Monorepo
Expected Behavior
@nrwl/jest:jest should run all tests in the React Native project, or running one test manually should succeed (or fail) based on the test predicate.
No, this has never worked on the repo I’m working with
Steps to Reproduce
No, but couldn’t find a Typescript or React Native app in that repo.
The web app in this monorepo is able to be tested, but the React Native app fails no matter how I kick off the tests with the following error:
Failure Logs
` Test suite failed to run
TypeError: Cannot read properties of undefined (reading 'testEnvironmentOptions')
at new NodeEnvironment (../../node_modules/jest-environment-node/build/index.js:96:49)
at async TestScheduler.scheduleTests (../../node_modules/@jest/core/build/TestScheduler.js:333:13)
at async runJest (../../node_modules/@jest/core/build/runJest.js:404:19)
at async _run10000 (../../node_modules/@jest/core/build/cli/index.js:320:7)
at async runCLI (../../node_modules/@jest/core/build/cli/index.js:173:3)`
Environment
NX Report complete - copy this into the issue template
Node : 16.13.2 OS : darwin arm64 npm : 8.19.1
nx : 13.8.3 @nrwl/angular : undefined @nrwl/cli : 13.8.3 @nrwl/cypress : 13.8.3 @nrwl/detox : 13.8.3 @nrwl/devkit : 13.8.3 @nrwl/eslint-plugin-nx : 13.8.3 @nrwl/express : undefined @nrwl/jest : 13.8.3 @nrwl/js : 13.8.3 @nrwl/linter : 13.8.3 @nrwl/nest : undefined @nrwl/next : undefined @nrwl/node : undefined @nrwl/nx-cloud : undefined @nrwl/react : 13.8.3 @nrwl/react-native : 13.8.3 @nrwl/schematics : undefined @nrwl/storybook : 13.8.3 @nrwl/tao : 13.8.3 @nrwl/web : 13.8.3 @nrwl/workspace : 13.8.3 typescript : 4.4.4 rxjs : 6.6.7
Community plugins:
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Jest: testEnvironmentOptions cannot be read - Stack Overflow
Jest: testEnvironmentOptions cannot be read ... TypeError: Cannot read properties of undefined (reading 'testEnvironmentOptions') at new ...
Read more >Jest: Cannot read properties of undefined (reading ...
The Jest "TypeError: Cannot read properties of undefined (reading 'testEnvironmentOptions')" occurs for 2 main reasons: Having incompatible versions of jest and ...
Read more >cannot read property 'testenvironmentoptions' of undefined
TypeError : Cannot read properties of undefined (reading 'testEnvironmentOptions') at new NodeEnvironment (node_modules/jest-environment-node/build/index.js:96: ...
Read more >jest-environment-jsdom | Yarn - Package Manager
... [@jest/reporters] Fix Cannot read property converageData of null (#8168) ... [expect] Fix TypeError in toBeInstanceOf on null or undefined (#6912) ...
Read more >Configuring Jest
Jest will run .mjs and .js files with nearest package.json 's type field set to module as ECMAScript Modules.
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
I have fixed my issue by adding and pinning the versions of jest-environment-node and jest-config to the same version as jest.
I am experiencing the same issue. My current workaround is to delete the testEnvironment property in jest.config.
I also tried jest-environment-jsdom and jest-environment-node, they didn’t work. listed in the documentation