mercredi 27 juillet 2016

Mocking navigator in RN for unit tests

For my tests, Am using mocha, enzyme, sinon for stubing and chai for assertions, mockery for mocking modules.

Now whats the best possible mechanism to mock navigator for geolocation. I tried rewire from http://ift.tt/Vko7Ef to inject my sinon stubed navigator. This will work for me, but just feels cumbersome to setup the stub. I like http://ift.tt/2arzYBE as it feels more natural way of mocking. But unfortunately am not able to use it because it uses window variable.

I run my tests like this mocha --require react-native-mock/mock --compilers js:babel-register --recursive

Aucun commentaire:

Enregistrer un commentaire