node.jsreact-nativedetox

Detox mocking using file extension e2e.js


I'm using Detox as an end to end testing framework for a react native application. I'd like to mock the results of API requests in order to reduce flakiness and time for testing.

According to the documentation, I should be able to have Metro overwrite a module using the file extension e2e.js.

I'm unable to get this working and I'm not entirely sure why. Most documentation and existing questions relate to using react-native-repackager, but as of RN 0.55.0, this is no longer needed.

Any help/ideas would be appreciated!

EDIT:

RN_SRC_EXT=e2e.js react-native start works fine

RN_SRC_EXT=e2e.js xcodebuild -project <other params> as the detox build script and detox test -c ios.sim.release does not work


Solution

  • rm -rf ios/build

    Had to clear my previous build cache and files, then it worked :)