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

Mocking with RN Detox

$
0
0

I am following the detox mocking guide with typescript. The app always prints console.log of X.ts file instead of X.e2e.ts file.

Dependency version.

react-native: 0.61.5,detox: 16.4.0

Metro Configuration:

"detox": {"test-runner": "jest","runner-config": "e2e/config.json","configurations": {"ios.sim.debug": {"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/App.app","build": "RN_SRC_EXT=e2e.js,e2e.ts xcodebuild -workspace ios/App.xcworkspace -scheme 'App Test' -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build","type": "ios.simulator","device": {"type": "iPhone 11"        }      }    }  }

metro.config.js

const defaultSourceExts = require("metro-config/src/defaults/defaults").sourceExts;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  }};console.log("default", defaultSourceExts);console.log("module.exports from e2e", module.exports);/** above console results into the followingdefault [ 'js', 'json', 'ts', 'tsx' ]module.exports from e2e { transformer:   { getTransformOptions: [AsyncFunction: getTransformOptions] },  resolver: { sourceExts: [ 'e2e.ts', 'js', 'json', 'ts', 'tsx' ] } }*/

/src/AppEvent.js

const logEvent = (): void => {  console.log("from non-test event file");};export default {  logEvent};

/src/AppEvent.e2e.ts

const logEvent = (): void => {  console.log("from test event file");};export default {  logEvent};

When I run detox build && detox test metro server doesn't log e2d files, So I had to run metro separately using RN_SRC_EXT=e2e.js,e2e.ts yarn start


Viewing all articles
Browse latest Browse all 6213

Trending Articles



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