【问题标题】:React Native Detox mocking filesReact Native Detox 模拟文件
【发布时间】:2019-08-08 23:20:15
【问题描述】:

请有人告诉我模拟文件如何反应原生排毒测试?我关注this article

我正在使用 react-native 版本 0.57.7 和 detox 9.1.2

我在根目录下创建了 rn-cli.config.js

const defaultSourceExts = require('metro-config/src/defaults/defaults').sourceExts
module.exports = {
  resolver: { 
    sourceExts: process.env.RN_SRC_EXT
                ? process.env.RN_SRC_EXT.split(',').concat(defaultSourceExts)
                : defaultSourceExts
  }
};

我在具有 e2e 扩展名的生产文件旁边创建了模拟文件

然后我用命令运行 Metro(我使用的是 windows powershel 6)

$env:RN_SRC_EXT="e2e.ts";react-native start
react-native run-android

什么都没有,实际上没有任何改变/嘲笑

我也尝试构建并运行 detox

cd android;$env:ENVFILE="../config/default/env";gradle assembleDebug assembleAndroidTest -DtestBuildType=debug;cd ..
detox test -c android.emu.debug.win

但也没有发生任何事情,我删除了所有 node_modules、android 构建文件夹但没有效果。

我错过了什么吗?

【问题讨论】:

    标签: react-native detox


    【解决方案1】:

    您的rn-cli.config.js 文件是正确的,但请尝试将其添加到您的排毒e2e/config.json

    "testMatch": ["**/__tests__/**/*.js?(x)", "**/?(*.)(e2e).js?(x)"]
    

    我的是这样的:

    {
        "setupFilesAfterEnv": ["./init.js"],
        "testEnvironment": "node",
        "reporters": ["detox/runners/jest/streamlineReporter"],
        "testMatch": ["**/__tests__/**/*.js?(x)", "**/?(*.)(e2e).js?(x)"],
        "verbose": true
    }
    

    我正在使用 react-native 版本 0.59.8 和 detox 12.10.2

    当你使用打字稿时,那么写

    "testMatch": ["**/__tests__/**/*.ts?(x)", "**/?(*.)(e2e).ts?(x)"],
    

    带有 ts 扩展名

    【讨论】:

      猜你喜欢
      • 2021-01-07
      • 2020-10-02
      • 2020-09-01
      • 2018-10-11
      • 2023-03-29
      • 2018-09-22
      • 2020-11-06
      • 1970-01-01
      • 2019-01-17
      相关资源
      最近更新 更多