vendredi 29 juillet 2016

mockery not able to register substitute

I have a problem registering substitutes with mockery. My usecase is that I want to substitute react-native-router-flux with my own. So I created a file rn-router-mock.js which resides in a path something like ./../test/mock/rn-router-mock relative to my test file.

My code mockery.registerSubstitute('react-native-router-flux', './../test/mock/rn-router-mock') fails with an error

Error: Cannot find module './../../test/mock/rn-router-mock'
    at Function.Module._resolveFilename (module.js:325:15)
    at Module._load (module.js:276:25)

However note that I am able to require('./../test/mock/rn-router-mock') from the same test code.

And the same works when I give the full path to the mock module.

Any help will be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire