我根据文档https://github.com/wix/detox/blob/master/docs/APIRef.Configuration.md指定了配置。
"detox": {
"configurations": {
"ios.sim.debug": {
"binaryPath": ".....",
"build": ".....",
"type": "ios.simulator",
"name": "iPad Air 2"
}
},
"session": {
"server": "ws://localhost:8099",
"sessionId": "YourProjectSessionId"
},
"test-runner": "mocha",
"specs": "test/e2e",
"runner-config": "test/e2e/mocha.opts"
}
我希望排毒在端口8099上运行排毒服务器。
但是开始测试时
detox test --loglevel verbose
发生以下错误
detox ERR! ws onError: Error: connect ECONNREFUSED 127.0.0.1:8099
{ Error: connect ECONNREFUSED 127.0.0.1:8099
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 8099,
type: 'error',
target:
WebSocket {
domain: null,
_events: { error: [Function: onerror] },
_eventsCount: 1,
_maxListeners: undefined,
_socket: null,
_ultron: null,
_closeReceived: false,
bytesReceived: 0,
readyState: 3,
supports: { binary: true },
extensions: null,
_binaryType: 'nodebuffer',
_isServer: false,
url: 'ws://localhost:8099',
protocolVersion: 13,
_closeTimer: null,
_closeCode: 1006 } }
child_process.js:644
throw err;
^
Error: Command failed: node_modules/.bin/mocha test/e2e --opts test/e2e/mocha.opts --configuration ios.sim.debug --loglevel verbose --grep :android: --invert
at checkExecSyncError (child_process.js:601:13)
at Object.execSync (child_process.js:641:13)
at runMocha (/Users/sbt-yakimov-vi/Desktop/cib/node_modules/detox/local-cli/detox-test.js:114:6)
at run (/Users/sbt-yakimov-vi/Desktop/cib/node_modules/detox/local-cli/detox-test.js:75:7)
at Object.<anonymous> (/Users/sbt-yakimov-vi/Desktop/cib/node_modules/detox/local-cli/detox-test.js:181:1)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
在生成的端口上运行时,一切正常
答案 0 :(得分:1)
您必须使用以下代码自行运行服务器
const DetoxServer = require('detox-server')
const URL = require('url').URL;
await new DetoxServer(new URL(config.session.server).port)
Json应该包含
"session": {
"server": "ws://localhost:8099",
"sessionId": "cib_app"
}