oro*_*ome 6 ios react-native detox
以下后设立排毒的基本指令为我简单的示例项目,并运行一个成功的detox build,detox test产生下面的输出,即使只测试配置我有我的package.json是iOS版:
{
"name": "Learn",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.4.1",
"react-native": "0.56.0"
},
"devDependencies": {
"babel-jest": "23.4.0",
"babel-preset-react-native": "5.0.2",
"detox": "^8.0.0",
"jest": "^23.4.1",
"react-test-renderer": "16.4.1"
},
"jest": {
"preset": "react-native"
},
"detox": {
"configurations": {
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/Learn.app",
"build": "xcodebuild -project ios/Learn.xcodeproj -scheme Learn -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone 6"
}
},
"test-runner": "jest"
}
}
Run Code Online (Sandbox Code Playgroud)
错误中提到的文件是在安装过程中没有更改的情况下提供的,其内容如下:
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
module.exports = require('./configs/main');
Run Code Online (Sandbox Code Playgroud)
为什么 Detox 无法测试我的应用程序?
node_modules/.bin/jest e2e --config=e2e/config.json --maxWorkers=1 --testNamePattern='^((?!:android:).)*$'
FAIL e2e/firstTest.spec.js
? Test suite failed to run
Plugin 0 specified in "/Users/Rax/Documents/Projects/Coding/React/Learn/node_modules/babel-preset-react-native/index.js" provided an invalid property of "default" (While processing preset: "/Users/Rax/Documents/Projects/Coding/React/Learn/node_modules/babel-preset-react-native/index.js")
at Plugin.init (../node_modules/babel-core/lib/transformation/plugin.js:131:13)
at Function.normalisePlugin (../node_modules/babel-core/lib/transformation/file/options/option-manager.js:152:12)
at ../node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
at Array.map (<anonymous>)
at Function.normalisePlugins (../node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (../node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at ../node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14
at ../node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22
at Array.map (<anonymous>)
at OptionManager.resolvePresets (../node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.869s
Ran all test suites matching /e2e/i with tests matching "^((?!:android:).)*$".
child_process.js:643
throw err;
^
Error: Command failed: node_modules/.bin/jest e2e --config=e2e/config.json --maxWorkers=1 --testNamePattern='^((?!:android:).)*$'
at checkExecSyncError (child_process.js:603:11)
at Object.execSync (child_process.js:640:13)
at runJest (/Users/Rax/Documents/Projects/Coding/React/Learn/node_modules/detox/local-cli/detox-test.js:146:6)
at run (/Users/Rax/Documents/Projects/Coding/React/Learn/node_modules/detox/local-cli/detox-test.js:81:7)
at Object.<anonymous> (/Users/Rax/Documents/Projects/Coding/React/Learn/node_modules/detox/local-cli/detox-test.js:191:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
Run Code Online (Sandbox Code Playgroud)
: Searching for device matching iPhone 6...
: Booting device 7F2124D7-7A75-4702-9A88-926D0C5B884A
: running "/usr/bin/xcrun simctl io 7F2124D7-7A75-4702-9A88-926D0C5B884A screenshot "/dev/null"" returned 2
7: stderr: An error was encountered processing the command (domain=SimulatorKit.SimDisplayScreenshotWriter.ScreenshotError, code=2):
Error creating the image
Run Code Online (Sandbox Code Playgroud)
首先,Detox 没有运行 Android 测试。它看起来像这样只是因为正则表达式中的负向前瞻。
\n\n--testNamePattern=\'^((?!:android:).)*$\'
这是我刚刚运行的成功 iOS 测试的输出。
\n\ndetox test\nnode_modules/.bin/jest e2e --config=e2e/config.json --maxWorkers=1 --testNamePattern=\'^((?!:android:).)*$\'\n\n server listening on localhost:55356...\n\n : Searching for device matching iPhone 7...\n\n : Uninstalling com.testapp.test...\n\n : com.testapp.test uninstalled\n : Installing /Users/work/Documents/test/ios/build/Build/Products/Debug-iphonesimulator/test.app...\n : /Users/work/Documents/test/ios/build/Build/Products/Debug-iphonesimulator/test.app installed\n : Terminating com.testapp.test...\n : com.testapp.test terminated\n : Launching com.testapp.test...\n7: com.testapp.test launched. The stdout and stderr logs were recreated, you can watch them with:\n tail -F /Users/work/Library/Developer/CoreSimulator/Devices/AF406169-5CF3-4480-9D00-8F934C420043/data/tmp/detox.last_launch_app_log.{out,err}\n PASS e2e/firstTest.spec.js (10.504s)\n Example\n \xe2\x9c\x93 should have Home tab (1283ms)\n \xe2\x9c\x93 should show detail screen after tap (1872ms)\n\nTest Suites: 1 passed, 1 total\nTests: 2 passed, 2 total\nSnapshots: 0 total\nTime: 11.153s, estimated 12s\nRan all test suites matching /e2e/i with tests matching "^((?!:android:).)*$".\nRun Code Online (Sandbox Code Playgroud)\n\n关于您的测试未运行,我在将 React-Native 版本从 0.55 升级到 0.56 时遇到了这个问题。
\n\n我相信 Babel 存在问题导致了这种情况,因为 RN 0.56 现在需要Babel 7。
\n\n查看您的 package.json 似乎您应该添加到您的 devDependency
\n\n"@babel/core": "^7.0.0-beta.47",\n"babel-core": "^7.0.0-beta.47",\n
这个问题已经在React-Native github上讨论过了。
\n\n为了运行 Jest 测试,我发现我还必须添加\n"@babel/generator": "^7.0.0-beta.47"到我的 devDependency 中。
| 归档时间: |
|
| 查看次数: |
2781 次 |
| 最近记录: |