From 41440125cb8fd909a022b9e707eeccc67cd3100b Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 19 Sep 2017 15:45:05 -0700 Subject: [PATCH] Ensure RN has an event loop running for async tests --- tests/react-test-app/ios/ReactTests/RealmReactTests.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/react-test-app/ios/ReactTests/RealmReactTests.m b/tests/react-test-app/ios/ReactTests/RealmReactTests.m index 746e31a6..27bacbe8 100644 --- a/tests/react-test-app/ios/ReactTests/RealmReactTests.m +++ b/tests/react-test-app/ios/ReactTests/RealmReactTests.m @@ -168,6 +168,7 @@ extern NSMutableArray *RCTGetModuleClasses(void); + (void)waitForCondition:(BOOL *)condition description:(NSString *)description { NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; NSDate *timeout = [NSDate dateWithTimeIntervalSinceNow:30.0]; + RCTBridge *bridge = [self currentBridge]; while (!*condition) { if ([timeout timeIntervalSinceNow] < 0) { @@ -180,6 +181,7 @@ extern NSMutableArray *RCTGetModuleClasses(void); [runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; [runLoop runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; [NSThread sleepForTimeInterval:0.01]; // Bad things may happen without some sleep. + [bridge.eventDispatcher sendAppEventWithName:@"realm-dummy" body:nil]; // Ensure RN has an event loop running } } }