我正在使用RN应用程序中的react-navigation进行导航。问题是当我运行排毒时,测试只是挂起,但是如果我删除导航并仅渲染React组件,则测试运行正常。以下是遵循本指南(https://github.com/wix/Detox/blob/master/docs/Guide.DebuggingInXcode.md)之后的日志(使用react-navigation时):
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
* frame #0: 0x00007fff23bd5a3a CoreFoundation`_CFRelease + 186
frame #1: 0x00007fff23bce337 CoreFoundation`__CFRunLoopDoObservers + 487
frame #2: 0x00007fff23bce97a CoreFoundation`__CFRunLoopRun + 1514
frame #3: 0x00007fff23bce066 CoreFoundation`CFRunLoopRunSpecific + 438
frame #4: 0x000000010207ba6a EarlGrey`-[GREYRunLoopSpinner grey_drainRunLoopInActiveModeAndCheckCondition:forTime:](self=0x0000600002a524f0, _cmd="grey_drainRunLoopInActiveModeAndCheckCondition:forTime:", stopConditionBlock=0x00000001020c9560, time=1.7976931348623157E+308) at GREYRunLoopSpinner.m:175:31
frame #5: 0x000000010207b435 EarlGrey`-[GREYRunLoopSpinner spinWithStopConditionBlock:](self=0x0000600002a524f0, _cmd="spinWithStopConditionBlock:", stopConditionBlock=0x00000001020c9560) at GREYRunLoopSpinner.m:58:26
frame #6: 0x00000001020c8cba EarlGrey`-[GREYUIThreadExecutor executeSyncWithTimeout:block:error:](self=0x000060000252c300, _cmd="executeSyncWithTimeout:block:error:", seconds=1.7976931348623157E+308, execBlock=0x000000010209aec0, error=0x00007ffeef3274d0) at GREYUIThreadExecutor.m:227:22
frame #7: 0x000000010209a3d1 EarlGrey`-[GREYElementInteraction assert:error:](self=0x0000600003b10a00, _cmd="assert:error:", assertion=0x00006000025db840, errorOrNil=0x0000000000000000) at GREYElementInteraction.m:436:9
frame #8: 0x000000010209bd4d EarlGrey`-[GREYElementInteraction assertWithMatcher:error:](self=0x0000600003b10a00, _cmd="assertWithMatcher:error:", matcher=0x00006000025db820, errorOrNil=0x0000000000000000) at GREYElementInteraction.m:481:10
frame #9: 0x000000010209bc7e EarlGrey`-[GREYElementInteraction assertWithMatcher:](self=0x0000600003b10a00, _cmd="assertWithMatcher:", matcher=0x00006000025db820) at GREYElementInteraction.m:476:10
frame #10: 0x00007fff23c7820c CoreFoundation`__invoking___ + 140
frame #11: 0x00007fff23c753af CoreFoundation`-[NSInvocation invoke] + 319
frame #12: 0x0000000101f1833f Detox`+[DTXMethodInvocation invoke:onError:](self=DTXMethodInvocation, _cmd="invoke:onError:", params=3 key/value pairs, onError=0x0000000101f10f60) at DTXMethodInvocation.m:246:2
frame #13: 0x0000000101f10bcc Detox`__35-[TestRunner invoke:withMessageId:]_block_invoke(.block_descriptor=0x0000600003b10ec0) at TestRunner.m:71:12
frame #14: 0x00007fff23bd429c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
frame #15: 0x00007fff23bd3a08 CoreFoundation`__CFRunLoopDoBlocks + 312
frame #16: 0x00007fff23bcee1b CoreFoundation`__CFRunLoopRun + 2699
frame #17: 0x00007fff23bce066 CoreFoundation`CFRunLoopRunSpecific + 438
frame #18: 0x000000010207ba6a EarlGrey`-[GREYRunLoopSpinner grey_drainRunLoopInActiveModeAndCheckCondition:forTime:](self=0x0000600002b84240, _cmd="grey_drainRunLoopInActiveModeAndCheckCondition:forTime:", stopConditionBlock=0x00000001020c9560, time=1.7976931348623157E+308) at GREYRunLoopSpinner.m:175:31
frame #19: 0x000000010207b435 EarlGrey`-[GREYRunLoopSpinner spinWithStopConditionBlock:](self=0x0000600002b84240, _cmd="spinWithStopConditionBlock:", stopConditionBlock=0x00000001020c9560) at GREYRunLoopSpinner.m:58:26
frame #20: 0x00000001020c8cba EarlGrey`-[GREYUIThreadExecutor executeSyncWithTimeout:block:error:](self=0x000060000252c300, _cmd="executeSyncWithTimeout:block:error:", seconds=1.7976931348623157E+308, execBlock=0x0000000101f09f70, error=0x0000000000000000) at GREYUIThreadExecutor.m:227:22
frame #21: 0x00000001020c8783 EarlGrey`-[GREYUIThreadExecutor executeSync:error:](self=0x000060000252c300, _cmd="executeSync:error:", execBlock=0x0000000101f09f70, error=0x0000000000000000) at GREYUIThreadExecutor.m:198:10
frame #22: 0x0000000101f09f46 Detox`__45-[EarlGreyImpl(.block_descriptor=0x0000600002b4c210) detox_safeExecuteSync:]_block_invoke at EarlGrey+Detox.m:17:3
frame #23: 0x00007fff23bd429c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
frame #24: 0x00007fff23bd3a08 CoreFoundation`__CFRunLoopDoBlocks + 312
frame #25: 0x00007fff23bce894 CoreFoundation`__CFRunLoopRun + 1284
frame #26: 0x00007fff23bce066 CoreFoundation`CFRunLoopRunSpecific + 438
frame #27: 0x00007fff384c0bb0 GraphicsServices`GSEventRunModal + 65
frame #28: 0x0000000101f0f8da Detox`__detox_UIApplication_run(self=0x00007fb6f0100900, _cmd="_run") at ReactNativeSupport.m:143:9
frame #29: 0x00007fff48092d4d UIKitCore`UIApplicationMain + 1621
frame #30: 0x00000001008d6930 DetoxTestApp`main(argc=1, argv=0x00007ffeef329c80) at main.m:14:12
frame #31: 0x00007fff5227ec25 libdyld.dylib`start + 1
(lldb)
运行测试时的终端日志:
detox[17781] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=7f3c526f-ba61-1c9e-8937-d08d09665fba)
detox[17781] DEBUG: [DetoxServer.js/LOGIN] role=testee, sessionId=7f3c526f-ba61-1c9e-8937-d08d09665fba
detox[17781] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=testee, sessionId=7f3c526f-ba61-1c9e-8937-d08d09665fba
detox[17781] INFO: <Login />: should expect email input
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.facebook.react.ShadowQueue
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.facebook.react.ShadowQueue
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync WXRunLoopIdlingResource: React Native thread is busy.
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.facebook.react.ShadowQueue
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync WXRunLoopIdlingResource: React Native thread is busy.
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: [actions.js] Sync JavaScript Timers: Javascript Timers
detox[17781] INFO: [actions.js] Sync Dispatch Queue: com.apple.main-thread
detox[17781] INFO: <Login />: should expect email input [FAIL]
detox[17781] WARN: [Client.js/PENDING_REQUESTS] App has not responded to the network requests below:
(id = 1) invoke: {"target":{"type":"Invocation","value":{"target":{"type":"EarlGrey","value":"instance"},"method":"detox_selectElementWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForAccessibilityID:","args":[{"type":"NSString","value":"email-input"}]}}]}},"method":"assertWithMatcher:","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"GREYMatchers"},"method":"matcherForSufficientlyVisible","args":[]}}]}
(id = -1000) isReady: {}
That might be the reason why the test "<Login /> should expect email input" has timed out.
detox[17781] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=7f3c526f-ba61-1c9e-8937-d08d09665fba
detox[17781] DEBUG: [DetoxServer.js/DISCONNECT] role=testee, sessionId=7f3c526f-ba61-1c9e-8937-d08d09665fba
detox[17781] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=tester not connected, cannot fw action (sessionId=7f3c526f-ba61-1c9e-8937-d08d09665fba)
detox[17781] DEBUG: [DetoxServer.js/WS_CLOSE] Detox server connections terminated gracefully
FAIL e2e/screen-navigation.test.js (121.37s)
<Login />
✕ should expect email input (60018ms)
● <Login /> › should expect email input
Timeout - Async callback was not invoked within the 60000ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 60000ms timeout specified by jest.setTimeout.
at mapper (../node_modules/jest-jasmine2/build/queueRunner.js:25:45)
● <Login /> › should expect email input
: Timeout - Async callback was not invoked within the 60000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 60000ms timeout specified by jest.setTimeout.Error:
12 | // });
13 |
> 14 | it('should expect email input', async () => {
| ^
15 | await expect(element(by.id('email-input'))).toBeVisible();
16 | });
17 |
at new Spec (../node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
at Suite.<anonymous> (screen-navigation.test.js:14:3)
at Object.<anonymous> (screen-navigation.test.js:2:1)
detox[17778] ERROR: [cli.js] Error: Command failed: node_modules/.bin/jest --config e2e/config.json '--testNamePattern=^((?!:android:).)*$' --maxWorkers 1 e2e
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
我的排毒init.js
文件:
const detox = require('detox');
const config = require('../package.json').detox;
const adapter = require('detox/runners/jest/adapter');
const specReporter = require('detox/runners/jest/specReporter');
// Set the default timeout
jest.setTimeout(60 * 1000);
jasmine.getEnv().addReporter(adapter);
// This takes care of generating status logs on a per-spec basis. By default, jest only reports at file-level.
// This is strictly optional.
jasmine.getEnv().addReporter(specReporter);
beforeAll(async () => {
console.log('**********INITSTART'); // --------------> this is logged
await detox.init(config, { launchApp: false });
console.log('**********INITDONE'); // --------------> this is logged
await device.launchApp({
newInstance: true,
launchArgs: {
detoxPrintBusyIdleResources: 'YES',
},
});
console.log('**********LAUNCHED'); // ------------> this is not logged
});
beforeEach(async () => {
await adapter.beforeEach();
});
afterAll(async () => {
await adapter.afterAll();
await detox.cleanup();
});
如果我不渲染导航器,而只是渲染Normal反应组件(例如),那么在device.launchApp登录到之后,一切正常(console.log('********** LAUNCHED'))终点站)。但是,如果我渲染Navigator,则console.log('********** LAUNCHED')不会记录到终端,并且会打印上面粘贴的日志。
版本:
react-navigation and dependencies: