量角器与递延boostrapping [英] protractor with deferred boostrapping

查看:162
本文介绍了量角器与递延boostrapping的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立终端到终端的测试我们的角度应用程序,但跨越一些障碍正在到来。

一是引导。我们使用这个库:角延期引导来引导我们的应用程序。这个库使我们能够HTTP调用的结果,那么它的注入我们的应用程序(如角值())。然后,它调用引导函数实际上角度引导的应用程序。我想测试运行后,这个boostrapping就完成了。

这是我迄今所做

 描述('导航应该',函数(){
    beforeEach(函数(){
        //加载网页
        browser.get('/');
    },10000);    它('秀侧面导航',函数(){
        browser.wait(函数(){
            VAR递延= protractor.promise.defer();            元素(by.css('body.deferred-引导装载'))是present()
                。然后(功能(为present){
                    deferred.fulfill(!是present);
                });            返回deferred.promise;
        });
    });
});

该库方便地将一个延期引导加载类的<​​code>体。我等待直到被删除。

问题是,有时我得到的错误错误等待量角器与网页同步:[NG:测试]没有注入发现元素参数getTestability \\ nhttp://errors.angularjs .ORG / 1.4.8 / NG /测试

这似乎更经常产生这种错误比它(测试)合格。

我不明白的问题是什么吗?是量角器角运行前有机会跑?

请问我要运行我的回调为 browser.wait 中的所有测试返回一个承诺?

此外,我想这code为每一个试运行(等待自举完成)。什么是组织最好的方法?


解决方案

我会尝试做的是关闭同步,直到预期的条件满足的:

  beforeEach(函数(){
    VAR EC = protractor.ExpectedConditions;    browser.ignoreSynchronization = TRUE;
    browser.get('/');    //等待延迟引导身体不是present
    VAR体= $(body.deferred-引导加载);
    browser.wait(EC.stalenessOf(体),10000)。然后(函数(){
        browser.ignoreSynchronization = FALSE;
    });
    browser.waitForAngular(); //可能并不需要
});



  

此外,我想这code为每一个试运行(等待自举完成)。什么是组织最好的方法?


请参阅:

I am attempting to set up end-to-end tests for our angular app but am coming across a few hurdles.

One is bootstrapping. We are using this library: angular-deferred-bootstrap to bootstrap our application. This library allows us to make http calls the result of which is then injected into our app (as angular value()). Then it calls the bootstrap function to actually bootstrap the app with angular. I want the tests to run after this boostrapping is complete.

This is what I have done so far

describe('navigation should', function () {
    beforeEach(function () {
        // load homepage
        browser.get('/');
    }, 10000);

    it('show side navigation', function () {
        browser.wait(function () {
            var deferred = protractor.promise.defer();

            element(by.css('body.deferred-bootstrap-loading')).isPresent()
                .then(function (isPresent) {
                    deferred.fulfill(!isPresent);
                });

            return deferred.promise;
        });
    });
});

The library conveniently puts a deferred-bootstrap-loading class on the body. I am waiting until this is removed.

Problem is sometimes I am getting the error Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.4.8/ng/test".

It seems to produce this error more often than it (the test) passing.

I don't understand what the issue is here? Is protractor running before angular has had a chance to run?

Would I have to run all my tests inside a callback as browser.wait returns a promise?

Also I would want this code to run for every test (wait for bootstrapping to finish). What is the best way to organize this?

解决方案

What I would try to do is to turn the synchronization off until the expected condition is met:

beforeEach(function () {
    var EC = protractor.ExpectedConditions;

    browser.ignoreSynchronization = true;
    browser.get('/');

    // wait for deferred bootstrap body to not be present
    var body = $("body.deferred-bootstrap-loading");
    browser.wait(EC.stalenessOf(body), 10000).then(function () {
        browser.ignoreSynchronization = false;
    });
    browser.waitForAngular();  // might not be needed
});


Also I would want this code to run for every test (wait for bootstrapping to finish). What is the best way to organize this?

Please see:

这篇关于量角器与递延boostrapping的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆