以某种方式运行我们的e2e排毒测试时,我们总是等待一些同步完成(如果我们禁用它并等待手动它可以工作)。
我尝试删除所有动画,但不知何故还有一些东西正在运行。
日志显示以下内容:
detox info Sync App State: undefined
detox info Sync Dispatch Queue: com.apple.main-thread
detox verb ws send: {"type":"currentStatus","params":{},"messageId":21}
detox verb ws onMessage: {"type":"currentStatusResult","messageId":21,"params":{"state":"busy","resources":[{"name":"App State","info":{"elements":["<UIViewController: 0x7fdc1351bf50>"],"appState":"Waiting for window's root view controller's view to appear."}},{"name":"Dispatch Queue","info":{"queue":"<OS_dispatch_queue_main: com.apple.main-thread[0x112beadc0] = { xref = -2147483648, ref = -2147483648, sref = 1, target = com.apple.root.default-qos.overcommit[0x112bec300], width = 0x1, state = 0x001ffe9e00000400, dirty, max qos 6, in-flight = 0, thread = 0x403 }>","prettyPrint":"com.apple.main-thread"}}],"messageId":21}}
detox verb ws
detox info Sync App State: undefined
detox info Sync Dispatch Queue: com.apple.main-thread
detox verb ws send: {"type":"currentStatus","params":{},"messageId":22}
detox verb ws onMessage: {"type":"currentStatusResult","messageId":22,"params":{"state":"busy","resources":[{"name":"App State","info":{"elements":["<UIViewController: 0x7fdc1351bf50>"],"appState":"Waiting for window's root view controller's view to appear."}},{"name":"Dispatch Queue","info":{"queue":"<OS_dispatch_queue_main: com.apple.main-thread[0x112beadc0] = { xref = -2147483648, ref = -2147483648, sref = 1, target = com.apple.root.default-qos.overcommit[0x112bec300], width = 0x1, state = 0x001ffe9e00000400, dirty, max qos 6, in-flight = 0, thread = 0x403 }>","prettyPrint":"com.apple.main-thread"}}],"messageId":22}}
此问题来自高度赞赏的任何帮助
[更新2018/04/18]:
只是为了澄清:
我的app组件的渲染功能就像:
render() {
const {
isOnboardingVisible,
} = this.props;
if (isOnboardingVisible) {
return (
<View>
<Onboarding onPressButton={this.props.onOnboardingViewed} />
</View>
);
}
return <LoginScreen statusBarHidden {!!this.props.notification} />;
};
测试通过更改isOnboardingVisible
道具从登录屏幕导航到登录屏幕,并卡在登录屏幕中等待元素可见(它在屏幕上清晰可见)。
如果我删除了入门屏幕并直接在登录屏幕上开始测试,则测试可以正常进行。
以下是评论中要求的AppDelegate.m:
#import "AppDelegate.h"
#import <CodePush/CodePush.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <BugsnagReactNative/BugsnagReactNative.h>
#import <Fabric/Fabric.h>
#import <Crashlytics/Crashlytics.h>
#import <react-native-branch/RNBranch.h>
#import "OneSignalConfig.h"
#import <React/RCTPushNotificationManager.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
@implementation AppDelegate
@synthesize oneSignal = _oneSignal;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
NSDictionary *plistDict = [NSDictionary dictionaryWithContentsOfFile:filePath];
[GIDSignIn sharedInstance].clientID = [plistDict objectForKey:@"CLIENT_ID"];
#ifdef FREEWORK_DEBUG
[RNBranch useTestInstance];
#endif
#ifdef FREEWORK_EDGE
[RNBranch useTestInstance];
#endif
#ifdef FREEWORK_STAGING
[RNBranch useTestInstance];
#endif
[RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];
NSURL *jsCodeLocation;
#ifdef DEBUG
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
jsCodeLocation = [CodePush bundleURL];
#endif
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"Freework"
initialProperties:nil
launchOptions:launchOptions];
rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
OneSignalConfig* config = [[OneSignalConfig alloc] init];
self.oneSignal = [[RCTOneSignal alloc] initWithLaunchOptions:launchOptions
appId: [config getOneSignalAppId]
settings:@{kOSSettingsKeyAutoPrompt: @false}];
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
rootViewController.view = rootView;
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
[BugsnagReactNative start];
[Fabric with:@[[Crashlytics class]]];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL handled = [[GIDSignIn sharedInstance] handleURL:url
sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
return handled;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
if (![RNBranch.branch application:application openURL:url sourceApplication:sourceApplication annotation:annotation]) {
if ([LinkedinSwiftHelper shouldHandleUrl:url]) {
return [LinkedinSwiftHelper application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
} else if ([[GIDSignIn sharedInstance] handleURL:url
sourceApplication:sourceApplication
annotation:annotation]) {
return YES;
} else if( [url.absoluteString rangeOfString: @"fb" ].location != NSNotFound ) {
return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
} else {
}
}
return YES;
}
// Respond to Universal Links
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler {
return [RNBranch continueUserActivity:userActivity];
} // Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
}
// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
// Required for the registrationError event.
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
}
// Required for the localNotification event.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
[RCTPushNotificationManager didReceiveLocalNotification:notification];
}
@end