Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

react-native run-ios is taking .e2e.ts file instead of .ts file

$
0
0

I'm dealing with a curious issues : I'm using detox for e2e testing, and in order to mock my API, I'm using two files:

  • api-service.ts : The API Service for my app
  • api-service.e2e.ts : The API Mock for testing

With detox, all is working : RN_SRC_EXT=e2e.ts detox build -c ios && detox test -c ios and my tests perfectly works.

But when I start the app with react-native run-ios it's the mock file that is used instead of the normal file.

While debugging I've trying multiple way:

  • Print a big console.log "GOOD FILE" in the "normal file" and "WRONG FILE" in the mock file (surprise, it's WRONG FILE which is logged each time)
  • Explicitly run RN_SRC_EXT=anythingButNote2eExt.ts react-native run-ios
  • Remove ios/build folder ❌
  • Remove api-service.e2e.ts✅ (oh it's work here)
  • Restore api-service.e2e.ts after removing it ❌ (😭)

More curious when I run RN_SRC_EXT=qwerty.ts detox build -c ios && detox test -c ios the test fail and so take the right api-service.ts file...

I've also double check: the file api-service.e2e.ts isn't imported from any file of the whole project, and the env variable RN_SRC_EXT isn't globally set.

So I'm completely lost and I can't find any problem of this kind on the internet. Your help will be extremely appreciated.

Thanks.

PS : as you see with the file extension, I'm using typescript but I don't think that's the cause of the problem.

EDIT : More details, my metro.config.js look like :

const defaultSourceExts = require("metro-config/src/defaults/defaults").sourceExts;console.log("Resolver EXT", process.env.RN_SRC_EXT);module.exports = {  transformer: {    getTransformOptions: async () => ({      transform: {        experimentalImportSupport: false,        inlineRequires: false,      },    }),  },  resolver: {    sourceExts: process.env.RN_SRC_EXT      ? process.env.RN_SRC_EXT.split(",").concat(defaultSourceExts)      : defaultSourceExts,  },};

And the console.log("Resolver EXT", process.env.RN_SRC_EXT); Always log e2e.ts even if I set this variable with other value...


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>