在运行e2e测试套件时,尤其是在CI(Bitrise)上运行时,我们遇到了问题。
在测试套件中,一些测试(每次运行都会有所不同)会出现以下错误:
{
cars:
[
{company: "Ford", timestamp:"123133131" },
{company: "Mercedes", timestamp:"12165433131" },
],
planes:
[
{company: "Foo", timestamp:"3123213114"},
{company: "Bar", timestamp:"3123213114"},
]
}
实际发生的是模拟器冻结并变得无响应(无法单击任何东西,使用键盘,使用渲染的电源按钮将其关闭;您需要使用Cmd + W杀死它,或者使用“硬件”菜单重新启动) 。发生这种情况时,给定文件中的所有后续测试都会失败,并显示超时错误。
然后,当我们开始一个新的测试套件(新的规范文件)时,Detox将打开一个新的模拟器,然后进行测试……直到再次发生这种情况。 我已经看到它在测试套件中发生了2次,导致3个模拟器处于打开状态(其中2个处于冻结状态)。
日志
● Test suite failed to run
Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.
at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)
通过其他测试记录
detox[37080] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onBeforeEach({ title: 'should go to OOO page',
fullName: 'Backup Plan Preferences should go to OOO page',
status: 'running' })
detox[37080] TRACE: [Artifact.js/START] starting SimulatorLogRecording
detox[37080] DEBUG: [exec.js/EXEC_CMD, #36] /usr/bin/xcrun simctl get_app_container 2CF919FD-473E-4386-9EE0-57A0DD2009E1 com.myeatclub.EAT-Club
detox[37080] TRACE: [exec.js/EXEC_SUCCESS, #36] /Users/magdalenastrzoda/Library/Developer/CoreSimulator/Devices/2CF919FD-473E-4386-9EE0-57A0DD2009E1/data/Containers/Bundle/Application/F833DF08-D432-4AFE-AD50-E5311F77F0B8/EatClubMobileApp.app
detox[37080] DEBUG: [exec.js/SPAWN_CMD, #37] [pid=47331] /usr/bin/xcrun simctl spawn 2CF919FD-473E-4386-9EE0-57A0DD2009E1 log stream --level debug --style compact --predicate "processImagePath beginsWith \"/Users/magdalenastrzoda/Library/Developer/CoreSimulator/Devices/2CF919FD-473E-4386-9EE0-57A0DD2009E1/data/Containers/Bundle/Application/F833DF08-D432-4AFE-AD50-E5311F77F0B8/EatClubMobileApp.app\""
detox[37080] TRACE: [Artifact.js/START] starting SimulatorVideoRecording
detox[37080] DEBUG: [exec.js/SPAWN_CMD, #38] [pid=47333] /usr/bin/xcrun simctl io 2CF919FD-473E-4386-9EE0-57A0DD2009E1 recordVideo /private/var/folders/qk/07x9s51136jdkzv7t2_q2n5h0000gp/T/3023bd5e-9332-42d0-bbc2-011dd505fea0.mp4
detox[37080] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"reactNativeReload","params":{},"messageId":-1000}
detox[37080] TRACE: [DetoxServer.js/MESSAGE] role=tester action=reactNativeReload (sessionId=5044f1e4-f0af-d762-ef72-799282ef295b)
detox[37080] TRACE: [DetoxServer.js/MESSAGE] role=testee action=ready (sessionId=5044f1e4-f0af-d762-ef72-799282ef295b)
detox[37080] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"type":"ready","messageId":-1000,"params":{}}
detox[37080] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"invoke","params":{"target":{"type":"Invocation","value":{"target":{"type":"EarlGrey","value":"instance"},"method":"detox_selectElementWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"detoxMatcherForBoth:and:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForAccessibilityID:","args":[{"type":"NSString","value":"account"}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForSufficientlyVisible","args":[]}}]}}]}},"method":"performAction:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYActions"},"method":"actionForTap","args":[]}}]},"messageId":312}
detox[37080] TRACE: [DetoxServer.js/MESSAGE] role=tester action=invoke (sessionId=5044f1e4-f0af-d762-ef72-799282ef295b)
detox[37080] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"invoke","params":{"target":{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYCondition"},"method":"detoxConditionForElementMatched:","args":[{"type":"Invocation","value":{"target":{"type":"EarlGrey","value":"instance"},"method":"detox_selectElementWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"detoxMatcherForBoth:and:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"detoxMatcherForText:","args":[{"type":"NSString","value":"Out of Office"}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForNotNil","args":[]}}]}}]}}]}},"method":"waitWithTimeout:","args":[{"type":"CGFloat","value":4}]},"messageId":313}
detox[37080] TRACE: [DetoxServer.js/MESSAGE] role=tester action=invoke (sessionId=5044f1e4-f0af-d762-ef72-799282ef295b)
Backup Plan Preferences: should go to OOO page [FAIL]
detox[37080] TRACE: [Detox.js/DETOX_AFTER_EACH] failed test: "Backup Plan Preferences should go to OOO page"
detox[37080] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onAfterEach({ title: 'should go to OOO page',
fullName: 'Backup Plan Preferences should go to OOO page',
status: 'failed',
timedOut: true })
detox[37080] TRACE: [Artifact.js/STOP] stopping SimulatorVideoRecording
detox[37080] DEBUG: [exec.js/KILL] sending SIGINT to [pid = 47333]: /usr/bin/xcrun simctl io 2CF919FD-473E-4386-9EE0-57A0DD2009E1 recordVideo /private/var/folders/qk/07x9s51136jdkzv7t2_q2n5h0000gp/T/3023bd5e-9332-42d0-bbc2-011dd505fea0.mp4
FAIL e2e/backupPlan.spec.js
● Test suite failed to run
Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.
at mapper (node_modules/jest-jasmine2/build/queueRunner.js:25:45)
detox[37080] INFO: [DetoxServer.js] [32mserver listening on localhost:50310...
detox[37080] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:50310
detox[37080] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"login","params":{"sessionId":"55fb73cb-c9d8-52cf-d2de-7411c43904da","role":"tester"},"messageId":0}
detox[37080] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=55fb73cb-c9d8-52cf-d2de-7411c43904da
detox[37080] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=55fb73cb-c9d8-52cf-d2de-7411c43904da
detox[37080] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"type":"loginSuccess","params":{"sessionId":"55fb73cb-c9d8-52cf-d2de-7411c43904da","role":"tester"},"messageId":0}
detox[37080] DEBUG: [exec.js/EXEC_CMD, #0] /usr/bin/xcrun simctl list -j
关于如何解决此问题的任何提示?
这使我们无法在CI上运行测试,因为这种情况至少发生50%。
环境