运行“排毒测试”时找不到模块@jest/reporters
Posted
技术标签:
【中文标题】运行“排毒测试”时找不到模块@jest/reporters【英文标题】:Cannot find module @jest/reporters when running 'detox test' 【发布时间】:2019-10-30 14:02:10 【问题描述】:在我的 React Native 项目中设置 Detox 时遇到了一些问题。 我的项目配置如下:
MacOS 版本:10.14.14 Xcode 10.2.1 命令行工具:10.2.1 版
package.json:
"name": "AppName",
"version": "0.1.0",
"private": true,
"devDependencies":
"babel-preset-react-native-stage-0": "^1.0.1",
"detox": "^12.11.0",
"jest": "^23.6.0",
"jest-react-native": "^18.0.0",
"mocha": "^6.1.4",
"react-test-renderer": "16.3.1"
,
"scripts":
"start": "react-native start",
"android": "react-native run-android",
"ios": "react-native run-ios",
"devtools": "react-devtools --port 8091",
"test": "jest"
,
"jest":
"preset": "react-native"
,
"dependencies":
"jail-monkey": "^2.1.1",
"react": "16.3.1",
"react-devtools": "^3.2.3",
"react-native": "~0.55.2",
"react-native-camera": "1.1.4",
"react-native-device-info": "^0.22.5",
"react-native-fs": "^2.13.3",
"react-native-image-resizer": "^1.0.0",
"react-native-mail": "^3.0.7",
"react-native-maps": "^0.21.0",
"react-native-permissions": "^1.1.1",
"react-native-signature-capture": "^0.4.9",
"react-native-sortable-list": "0.0.22",
"react-native-sound": "^0.10.12",
"react-native-splash-screen": "^3.1.1",
"react-native-sqlcipher-storage": "github:axsy-dev/react-native-sqlcipher-storage",
"react-native-swipe-gestures": "^1.0.2",
"react-native-swipeout": "^2.3.6",
"react-navigation": "^2.2.4",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-thunk": "^2.2.0",
"rn-fetch-blob": "^0.10.15"
,
"rnpm":
"assets": [
"./src/assets/fonts"
]
,
"detox":
"configurations":
"ios.sim.debug":
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/ProntoPOD.app",
"build": "xcodebuild -workspace ios/ProntoPOD.xcworkspace -scheme ProntoPOD -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone XR"
,
"test-runner": "jest"
最初我在按照安装指南中的说明安装 Jest 和 Detox 后出现以下错误:
构建系统信息 错误:多个命令产生'': 1)目标“双重转换”(项目“反应”)具有来自“/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/react-native/third-party/double-conversion-1.1.5/src/的复制命令bignum-dtoa.h' 到 '/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/ios/build/Build/Products/Debug-iphonesimulator/include/double-conversion/bignum-dtoa.h' 2)目标'double-conversion-tvOS'(项目'React')具有来自'/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/react-native/third-party/double-conversion-1.1.5/的复制命令src/bignum-dtoa.h' 到 '/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/ios/build/Build/Products/Debug-iphonesimulator/include/double-conversion/bignum-dtoa.h'
构建系统信息 错误:多个命令产生'': 1)目标“双重转换”(项目“反应”):Libtool /Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/ios/build/Build/Products/Debug-iphonesimulator/libdouble-conversion.a normal x86_64 2)目标'double-conversion-tvOS'(项目'React'):Libtool /Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/ios/build/Build/Products/Debug-iphonesimulator/libdouble-conversion.a normal x86_64
** 构建失败 **
detox[64617] 错误:[cli.js] 错误:命令失败:xcodebuild -workspace ios/ProntoPOD.xcworkspace -scheme ProntoPOD -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build
通过将 XCode 中的 Build System 更改为 Workspace Settings 下的 Legacy Build 解决了这个问题。现在出现以下错误,我不知道如何解决它:
错误:在路径“/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/detox/runners/jest/streamlineReporter.js”添加报告器时出错。找不到模块“@jest/reporters” 在reporters.forEach (/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:510:15) 在 Array.forEach () 在 TestScheduler._addCustomReporters (/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:497:15) 在 TestScheduler._setupReporters (/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:466:12) 在新的 TestScheduler (/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/TestScheduler.js:193:10) 在 /Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/runJest.js:452:27 在 Generator.next () 在步骤(/Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/runJest.js:107:30) 在 /Users/cbrobbel/ProntoProjects/prontopod/ProntoPOD/node_modules/jest/node_modules/jest-cli/build/runJest.js:118:15 在 processTicksAndRejections (internal/process/task_queues.js:86:5) detox[64758] 错误:[cli.js] 错误:命令失败:node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:android:) .)*$' "e2e"
任何帮助将不胜感激。 谢谢!
【问题讨论】:
【参考方案1】:如果这是由于对等依赖,您可以手动尝试npm install @jest/reporters
,因为对等依赖不会自动安装在 npm 3 向上。
【讨论】:
【参考方案2】:尝试运行
npm install @jest/reporters
npm install
【讨论】:
以上是关于运行“排毒测试”时找不到模块@jest/reporters的主要内容,如果未能解决你的问题,请参考以下文章
运行 ng serve 时找不到模块“@angular/compiler”
UnhandledPromiseRejectionWarning:错误:当我尝试运行我的代码时找不到模块'../database/db'