From 8dcef96fd8475fa7d5a0a6fd7b3ca488f051e48f Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 13 Apr 2017 04:38:13 -0700 Subject: [PATCH] Log to console in RCTTestRunner Reviewed By: fkgozali Differential Revision: D4875352 fbshipit-source-id: 68f9caf4f350d34b2fd180ff19353c698bfce452 --- Libraries/RCTTest/RCTTestModule.m | 3 +++ Libraries/RCTTest/RCTTestRunner.m | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Libraries/RCTTest/RCTTestModule.m b/Libraries/RCTTest/RCTTestModule.m index c5741e93d..dd2424d31 100644 --- a/Libraries/RCTTest/RCTTestModule.m +++ b/Libraries/RCTTest/RCTTestModule.m @@ -51,6 +51,9 @@ RCT_EXPORT_METHOD(verifySnapshot:(RCTResponseSenderBlock)callback) selector:self->_testSelector identifier:identifier error:&error]; + if (!success) { + RCTLogInfo(@"Failed to verify snapshot %@ (error: %@)", identifier, error); + } callback(@[@(success)]); }]; } diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index 6f3ed0563..e32af66bc 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -97,9 +97,12 @@ expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock { @autoreleasepool { __block NSString *error = nil; + RCTLogFunction defaultLogFunction = RCTGetLogFunction(); RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { if (level >= RCTLogLevelError) { error = message; + } else { + defaultLogFunction(level, source, fileName, lineNumber, message); } }); @@ -137,7 +140,7 @@ expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock [rootView removeFromSuperview]; - RCTSetLogFunction(RCTDefaultLogFunction); + RCTSetLogFunction(defaultLogFunction); NSArray *nonLayoutSubviews = [vc.view.subviews filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id subview, NSDictionary *bindings) { return ![NSStringFromClass([subview class]) isEqualToString:@"_UILayoutGuide"];