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?