It's not clear how to use this
pjcabrera opened this issue · 9 comments
I'm trying to use this package, to use mocha for unit testing in React Native, but I'm not having any luck.
After running npm install -g rn-nodeify
, I tried running rn-nodeify
, with no parameters, on the main project folder before running npm install mocha
. I also tried rn-nodeify node_modules/mocha
. I added require('mocha')
in my index.ios.js and it fails with the same error as if I hadn't run the rn-nodeify command. I'm just not sure if I'm using this right, or if there's something else I should do.
Could you write up instructions in the readme file, with an example of using rn-nodeify to load a node module in a React Native app?
+1
There is an example of how this work now: https://github.com/mvayngrib/adexample
Great! Thanks @siuying, for letting us know. Will try it out this weekend, as soon as I get a chance.
The example does not work. It fails during build of the Xcode project.
Hmm, the failure seems to be in the version of RN the example project uses, not with the example project per se. Something wrong with how the packager resolves the path to node_modules dependencies. Maybe it's something on my end.
The failure building the example seems to be caused by this: facebook/react-native#4968
Tried the workaround documented there, still didn't work. rn-nodeify continues to be a waste of time, apparently.
@pjcabrera hm, i don't run into that issue. Unfortunately I don't have any time to dedicate to usability at this point, slammed with projects.
I was finally able to run https://github.com/mvayngrib/adexample by modifying the package.json to use react-native@0.18.0 released a couple of days ago. I had to mock out console.time() and console.timeEnd(), or it would crash, as these methods are undefined in react-native.
Now I can finally try to use rn-nodeify for my original purpose: writing unit tests for my RN app using mocha & chai.
@pjcabrera oops, my bad. I must have been running it with the debugger open, which has console.time/console.timeEnd available. I wonder why 0.18.0 was necessary though. Anyway, glad to hear you got it working