diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index 41316360b..0da2c8388 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -15,6 +15,7 @@ #import "RCTRootView.h" #import "RCTTestModule.h" #import "RCTUtils.h" +#import "RCTContextExecutor.h" static const NSTimeInterval kTestTimeoutSeconds = 60; static const NSTimeInterval kTestTeardownTimeoutSeconds = 30; @@ -114,7 +115,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) // Take a weak reference to the JS context, so we track its deallocation later // (we can only do this now, since it's been lazily initialized) - weakJSContext = [[[bridge valueForKey:@"batchedBridge"] valueForKey:@"javaScriptExecutor"] valueForKey:@"context"]; + id jsExecutor = [bridge valueForKeyPath:@"batchedBridge.javaScriptExecutor"]; + if ([jsExecutor isKindOfClass:[RCTContextExecutor class]]) { + weakJSContext = [jsExecutor valueForKey:@"context"]; + } [rootView removeFromSuperview]; RCTSetLogFunction(RCTDefaultLogFunction);