Skip to content
This repository was archived by the owner on Dec 31, 2020. It is now read-only.
This repository was archived by the owner on Dec 31, 2020. It is now read-only.

React Native + Jest: Cannot find module 'react-dom' from 'mobxreact.cjs.development.js' #844

Description

@jayshah123

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:

bash-3.2$ npm test

> JestMobxChecker@0.0.1 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.

How to reproduce the issue

https://github.com/jayshah123/mobx-jest-test-error

  1. clone the repo
  2. npm install
  3. npm test

Versions

    "mobx": "^5.15.4",
    "mobx-react": "^6.1.8",
    "react": "16.9.0",
    "react-native": "0.61.5"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions