I am writing protractor test suites, and need to test something that is uses pages generated from another suite. I can only figure out one way to write the test, but it doesn't seem like a good way to write it:
var someStuffToSave = [];
describe('description of first thing', function(){
it('should generate some things', function(){
someStuffToSave.push(generateSomeThings());
});
it('should generate some things', function(){
someStuffToSave.push(generateSomeThings());
});
it('should generate some things', function(){
someStuffToSave.push(generateSomeThings());
element(by.id("something")).getText().then(function(){
for(var i = 0; i < someStuffToSave.length; i++) (function(){
var idx = i;
describe('thing analysis' + idx, function(){
it('should be something', function(){
expect(someStuffToSave[idx]).toEqual(true);
});
});
})();
});
});
});
I would much rather do something like this, but the problem is the internals of the second describe execute right away, and do not wait for the first describe to finish.
var someStuffToSave = [];
describe('description of some thing', function(){
it('should generate some things', function(){
someStuffToSave.push(generateSomeThings());
});
it('should generate some things', function(){
someStuffToSave.push(generateSomeThings());
});
it('should generate some things', function(){
someStuffToSave.push(generateSomeThings);
});
});
describe('analyzing things', function(){
for(var i = 0; i < someStuffToSave.length; i++)function(){
var idx = i;
describe('thing ' + idx, function(){
it('should be something', function(){
expect(someStuffToSave[idx]).toEqual(true);
});
});
}
});
is there some way to write this without the 'then' inside the it in the first describe?