【问题标题】:Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './build/types' is not defined by "exports" in .../node_modules/jest-circus/package.json错误 [ERR_PACKAGE_PATH_NOT_EXPORTED]:包子路径 './build/types' 未由 .../node_modules/jest-circus/package.json 中的“exports”定义
【发布时间】:2021-10-29 14:50:28
【问题描述】:

我正在尝试使用 jest 和 jest-circus 为我的 React Native 应用程序的 e2e 测试设置 detox。我可以通过运行detox build --configuration ios 来构建我的iOS 应用程序,但我无法使用detox run --configuration ios 运行示例firstTest.e2e.js 测试。我收到以下错误:

  ● Test suite failed to run

    Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './build/types' is not defined by "exports" in [project path]/node_modules/jest-circus/package.json

      at Object.<anonymous> (../node_modules/detox/runners/jest-circus/listeners/DetoxCoreListener.js:11:25)

detox[92379] ERROR: [cli.js] Command failed: jest --config e2e/config.json --testNamePattern '^((?!:android:).)*$' --maxWorkers 1 e2e

我的 package.json 安装了以下库:

"detox": "^18.12.1",

"jest": "^24.9.0",

"jest-circus": "^27.1.0",

我的 .detoxrc.json 文件如下所示:

{
  "testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "apps": {
    "ios": {
      "type": "ios.app",
      "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/appname.app",
      "build": "xcodebuild -workspace ios/appname.xcworkspace -scheme appname -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build EXCLUDED_ARCHS=arm64"
    }
  },
  "devices": {
    "simulator": {
      "type": "ios.simulator",
      "device": {
        "type": "iPhone 11"
      }
    }
  },
  "configurations": {
    "ios": {
      "device": "simulator",
      "app": "ios"
    }
  }
}

我的 e2e/config.json 文件如下所示:

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

这是一个相当古老的项目,我已经在使用 jest 进行单元测试。我想知道是否可能有其他配置文件干扰我的 e2e 配置,但似乎还无法弄清楚。欢迎任何帮助!

【问题讨论】:

    标签: react-native jestjs detox jest-circus


    【解决方案1】:

    你应该尝试另一个笑话马戏团版本:

    "jest": "^26.0.1",
    "jest-circus": "^26.0.1",
    

    【讨论】:

      猜你喜欢
      • 2021-12-10
      • 1970-01-01
      • 2020-10-14
      • 2021-12-28
      • 2021-12-31
      • 2021-01-05
      • 1970-01-01
      • 2022-01-15
      • 2020-09-26
      相关资源
      最近更新 更多