首页 > 解决方案 > 排毒 e2e 测试分配给未定义并跳过所有测试

问题描述

在我们的 react-native 项目中,我们使用 detox 进行 e2e 测试。这些工作正常,直到突然我们体验到测试套件被分配给未定义。奇怪的是,在将任何更改恢复到之前排毒工作的状态时,这个问题仍然存在。该问题存在于 iOS 和 Android 配置中。

排毒控制台错误,分配给未定义

(这个问题与这个问题类似,但是,到目前为止,detox 应该适用于我们的 react native 版本。)

我的 detoxrc.json

{
  "testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "configurations": {
    "ios": {
      "type": "ios.simulator",
      "binaryPath": "ios/build/Build/Products/Test-iphonesimulator/Cliniserve One.app",
      "build": "xcodebuild -workspace ios/shiftapp.xcworkspace -scheme shiftapp.test -configuration Test -sdk iphonesimulator -derivedDataPath ios/build",
      "device": {
        "type": "iPhone 11"
      }
    },
    "android": {
      "type": "android.emulator",
      "binaryPath": "android/app/build/outputs/apk/development/debug/shiftapp_development_debug.apk",
      "build": "cd android && ./gradlew assembleDevelopmentDebug assembleDevelopmentDebugAndroidTest -DtestBuildType=debug && cd ..",
      "device": {
        "avdName": "Pixel_API_29_AOSP"
      }
    }
  }
}

我的e2e/config.json

{
    "setupFilesAfterEnv" : ["./init.js"],
    "testEnvironment": "./environment",
    "testRunner": "jest-circus/runner",
    "testTimeout": 120000,
    "testRegex": "\\.e2e\\.js$",
    "reporters": ["detox/runners/jest/streamlineReporter"],
    "verbose": true
}

e2e/environment.js

const {
  DetoxCircusEnvironment,
  SpecReporter,
  WorkerAssignReporter,
} = require('detox/runners/jest-circus');

class CustomDetoxEnvironment extends DetoxCircusEnvironment {
  constructor(config) {
    super(config);

    // Can be safely removed, if you are content with the default value (=300000ms)
    this.initTimeout = 300000;

    // This takes care of generating status logs on a per-spec basis. By default, Jest only reports at file-level.
    // This is strictly optional.
    this.registerListeners({
      SpecReporter,
      WorkerAssignReporter,
    });
  }
}

module.exports = CustomDetoxEnvironment;

任何关于如何让它再次工作的帮助或想法将不胜感激。

标签: reactjsreact-nativejestjsdetox

解决方案


推荐阅读