Mobx: Test Error in React Native

Created on 6 Apr 2017  ·  4Comments  ·  Source: mobxjs/mobx

I have a issue:

We don't have react-dom in a React Native project,but it will be required in mobx-react.
The application performs normally but can't pass the test.

> jest

 FAIL  __tests__/index.ios.js
  ● Test suite failed to run

    Cannot find module 'react-dom' from 'index.js'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:169:17)
      at webpackUniversalModuleDefinition (node_modules/mobx-react/index.js:3:63)
      at Object.<anonymous> (node_modules/mobx-react/index.js:10:3)

 PASS  __tests__/index.android.js (6.962s)

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        8.674s
Ran all test suites.
npm ERR! Test failed.  See above for more details.
  1. Initialize a React Native project with react-native-cli
  2. yarn add mobx mobx-react
  3. import { observer } from 'mobx-react' in index.ios.js
  4. npm test

Most helpful comment

Using import { observer } from 'mobx-react/native' should solve that

All 4 comments

Using import { observer } from 'mobx-react/native' should solve that

Feel free to reopen if that doesn't solve the issue.

@mweststrate Thank you very much. I found some similar issues in mobx-react and it worked for me.

It would be nice if using 'mobx-react/native' was included in the documentation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidmoshal picture davidmoshal  ·  30Comments

mweststrate picture mweststrate  ·  75Comments

Nopik picture Nopik  ·  33Comments

mweststrate picture mweststrate  ·  37Comments

mweststrate picture mweststrate  ·  35Comments