Log to console in RCTTestRunner

Reviewed By: fkgozali

Differential Revision: D4875352

fbshipit-source-id: 68f9caf4f350d34b2fd180ff19353c698bfce452
This commit is contained in:
Pieter De Baets 2017-04-13 04:38:13 -07:00 committed by Facebook Github Bot
parent eeddef18b8
commit 8dcef96fd8
2 changed files with 7 additions and 1 deletions

View File

@ -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)]);
}];
}

View File

@ -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<UIView *> *nonLayoutSubviews = [vc.view.subviews filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id subview, NSDictionary *bindings) {
return ![NSStringFromClass([subview class]) isEqualToString:@"_UILayoutGuide"];