用我的应用创建了我的项目
这是project.json文件。我创造了
{
"name": "detox",
"version": "0.0.1",
"private": true,
"scripts": {
"ios": "react-native run-ios",
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"test:e2e":"navicotrackapp test",
"test:e2e:build":"navicotrackapp build"
},
"dependencies": {
"react": "16.6.1",
"react-native": "0.57.7"
},
"devDependencies": {
"babel-jest": "23.6.0",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.49.2",
"react-test-renderer": "16.6.1"
},
"jest": {
"preset": "react-native"
},
"detox": {
"configurations": {
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/navicotrackapp.app",
"build": "xcodebuild -project ios/navicotrackapp.xcodeproj -scheme navicotrackapp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone XR"
}
}
}
}
然而。当我运行测试时,这是出来的:
问题:
用这些替换你的scripts
值,然后再试一次:
"scripts": {
"ios": "react-native run-ios",
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"test:e2e":"npm run test",
"test:e2e:build":"npm run build" // THIS SCRIPT WILL STILL BREAK FOR YOU
},
最后两个是重要的!
如果脚本引用了npm run
中的另一个脚本,则需要使用yarn
或package.json
为脚本命令添加前缀。
所以,而不是一个调用navicotrackapp test
的脚本,它会调用npm run test
或yarn test
。
注意:
在您的示例中,看起来终端在脚本navicotrackapp build
上失败了。知道你没有定义build
脚本,所以如果用npm run build
替换脚本,它仍然会失败。如果你想让它工作,你需要添加一个build
脚本!
"scripts": {
"ios": "react-native run-ios",
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"build": // DO SOMETHING HERE!!!!,
"test:e2e":"npm run test",
"test:e2e:build":"npm run build"
},