You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 31, 2020. It is now read-only.
Test fails saying: Cannot find module 'react-dom' from 'mobxreact.cjs.development.js'
Full error:
bash-3.2$ npm test
> [email protected] test /Users/jay.shah/Documents/sampleapps/JestMobxChecker
> jest
FAIL __tests__/App-test.js
● Test suite failed to run
Cannot find module 'react-dom' from 'mobxreact.cjs.development.js'
However, Jest was able to find:
'./ColorComponent.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
However, Jest was able to find:
'../App.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:276:11)
at Object.<anonymous> (node_modules/mobx-react/dist/mobxreact.cjs.development.js:10:16)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.401s
Ran all test suites.
npm ERR! Test failed. See above for more details.
This will be generally solved by #787 once I get to finishing it up :)
For now, you basically have to force mobx-react in Jest config to resolve to RN bundle instead of regular CJS one.
Hm, that might not actually work because RN bundle uses ESM which Jest cannot handle afaik. Cannot think of any viable workaround for now so I guess it makes #787 fairly important now :)
@jayshah123 this PR makes the test run jayshah123/mobx-jest-test-error#1 . I didn't go any further than that though, so not sure if some more complicated tests relying on mobx will work too.)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or questions.
lockbot
locked as resolved and limited conversation to collaborators
Jun 24, 2020
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Having a fairly barebones react-native + mobx setup here (https://github.com/jayshah123/mobx-jest-test-error)
Running
npm test
asks forreact-dom
dependency.Intended outcome
Jest test should run as expected
Actual outcome
Test fails saying:
Cannot find module 'react-dom' from 'mobxreact.cjs.development.js'
Full error:
How to reproduce the issue
https://github.com/jayshah123/mobx-jest-test-error
Versions
The text was updated successfully, but these errors were encountered: