[ReactKit] Fail tests when redbox shows up

This commit is contained in:
Alex Kotliarskyi 2015-03-17 11:35:41 -07:00
parent 2aafcd0e58
commit e07c8db607

View File

@ -3,6 +3,8 @@
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "RCTRedBox.h"
#define TIMEOUT_SECONDS 240
@interface UIExplorerTests : XCTestCase
@ -29,11 +31,14 @@
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
BOOL foundElement = NO;
NSString *redboxError = nil;
while ([date timeIntervalSinceNow] > 0 && !foundElement) {
while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:date];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:date];
redboxError = [[RCTRedBox sharedInstance] currentErrorMessage];
foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
if ([view respondsToSelector:@selector(attributedText)]) {
NSString *text = [(id)view attributedText].string;
@ -45,6 +50,7 @@
}];
}
XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
XCTAssertTrue(foundElement, @"Cound't find element with '<View>' text in %d seconds", TIMEOUT_SECONDS);
}