react-native-mock
react-native-mock copied to clipboard
Issue using via package manager since build is required
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
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.
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 ?
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!)
@RealOrangeOne where can the rewrite version be found on npm? The version currently available on npm is pretty old.
@dannycochran Currently, it can't. The rewrite
branch is still Work in Progress. Hopefully there will be a beta to test soon
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