react-native-mock icon indicating copy to clipboard operation
react-native-mock copied to clipboard

Issue using via package manager since build is required

Open lalop opened this issue 7 years ago • 6 comments

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

lalop avatar Feb 05 '18 12:02 lalop

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.

RealOrangeOne avatar Feb 05 '18 14:02 RealOrangeOne

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 ?

lalop avatar Feb 06 '18 10:02 lalop

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 avatar Feb 06 '18 11:02 RealOrangeOne

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

dannycochran avatar Feb 16 '18 00:02 dannycochran

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

RealOrangeOne avatar Feb 16 '18 08:02 RealOrangeOne

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

gabrielrotbart avatar Feb 18 '18 04:02 gabrielrotbart