RealOrangeOne / react-native-mock

A fully mocked and test-friendly version of react native (maintainers wanted)
MIT License
570 stars 153 forks source link

Issue using via package manager since build is required #157

Open lalop opened 6 years ago

lalop commented 6 years ago

According to the documentation you used this library by adding require('react-native-mock/mock'); to tests. But react-native-mock/mock require ./build/react-native-mock.js which is not into the package when getting it via npm. So I add to run babel node_modules/react-native-mock/src --out-dir node_modules/react-native-mock/build before using this library.

Is that normal ?

nb: I used the rewrite branch

RealOrangeOne commented 6 years ago

This is normal, and intended. Only versions distributed through npm have the built source. Rather than that babel command, which doesnt look that great, you can do:

cd node_modules/react-native-mock && npm run build && cd -

to reuse the internal build script.

lalop commented 6 years ago

Reading the code I tried to call the react-native-mock like that require('react-native-mock/src/react-native-mock'); which seems to work the built version is only for non es6 support ?

RealOrangeOne commented 6 years ago

There are almost certainly other things the build does rather than just convert to ES5 (I forget off the top of my head). So whilst this isnt advised, it does work, yes. It's likely in future versions this will become less supported.

The highly recommended solution is to either run the version from npm, or run the build script.

(Saying that, testing for the rewrite branch is incredibly useful, so if you find any issues with it, be sure to let us know!)

dannycochran commented 6 years ago

@RealOrangeOne where can the rewrite version be found on npm? The version currently available on npm is pretty old.

RealOrangeOne commented 6 years ago

@dannycochran Currently, it can't. The rewrite branch is still Work in Progress. Hopefully there will be a beta to test soon

gabrielrotbart commented 6 years ago

The highly recommended solution is to either run the version from npm

I had to fork and update the dependencies to deal with #139 so can't run via npm (see @danReynolds solution). I think that's going to be happening to most people who are upgrading > 16