2017-04-12 125 views
2

最近,我一直在使用Protractor进行Angular应用的e2e测试。量角器:未检测角度应用

最近e2e测试已停止工作,因为量角器正在网站上搜索Angular,但没有找到它。我已经发布了这个作为issue,因为我的演示程序也遇到了问题。原来演示应用程序已损坏,但这并不能解决我的问题。

执行ng e2e时,具体的结果:

[15:00:22] E/protractor - Could not find Angular on page http://localhost:4200/ : angular never provided resumeBootstrap 
    HomePage tests 
    ✗ should have a title 
     - Failed: Angular could not be found on the page http://localhost:4200/.If this is not an Angular application, you may need to turn off waiting for Angular. 
     Please see https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular-on-page-load 

随着不久后跟随另一个错误:

- Failed: Error while waiting for Protractor to sync with the page: 
    "Cannot read property '$$testability' of undefined" 

随着使用ng new blabla我没有得到这个错误一个新的演示应用程序。所以它必须与Protractor正在等待的请求有关,但永远不会得到解决。

所以我的问题是: - 有没有人也遇到过这个问题? - 如果是这样,是否有步骤来检查量角器卡在哪里,所以我可以解决这个问题? - 或者这是量角器中的问题?

注意:使用browser.ignoreSynchronization = true时,量角器不会与Angular同步并运行规格,但我想要使用量角器功能,因此这不是长期的解决方案。

注:该应用程序使用角度,而不是AngularJS

+1

检查登录/ index.html页面中的ng-app指令。它在哪个标签中? –

+0

index.html文件中不需要ng-app指令,因为它是Angular应用程序,而不是AngularJS。我试过了,看看会发生什么,但最终会出现更多错误... – brvh

+0

好吧,在我的身体标记中添加了'ng-app =“app”'之前,它完全撞击了量角器。然而,当在body-tag中添加'ng-app'似乎已经成功了。我不明白为什么,如果这是正确的路,但现在至少没有更多的错误。 – brvh

回答

1

好吧,我已经找到了解决此两种可能的方法。

第一种解决方案是将 ... , "typeRoots": [ "../node_modules/@types" ] 添加到您的tsconfig.e2e.json文件中,该文件解决了该问题。这不包括在从@angular/cli生成的文件中。

另一个解决方案是增加ng-appindex.html文件的主体标签,但因为它看起来像比其他解决方案的更多黑客攻击的(与角混合AngularJS)我不喜欢这种解决方案。

+0

一种无关的但为了防止其他人...我们有一个闲置的检查器,它使用连续的setTimeout,并导致量角器认为该应用程序从未完成加载并抛出此错误。 – joshhunt