i'm trying to test an application that displays graphs using rickshaw and d3. tests are implemented using protractor and jasmine. as a side note, i believe the question is not really specific to this use case and is more generic.
so, the test is supposed to hover a mouse over a graph and collect the text that is shown for each point (example). this array is then to be matched against a given array.
i hope this pseudocode illustrates the problem:
var graph = ... //
var promises = [];
var promise = graphElement.getSize().then(function(size){
_.times(size, function(i) {
moveMouse(i, 0); // move mouse to i-th pixel
promises.push(graph.element(by.css('.hover-text')).getText());
});
return promises;
});
promise.magicallyWaitForAllOfThem();
_.each(promises, function(textPromise){
expect(textPromise).toBe('something');
});
so, the problem is that since i need the size to resolve first, i don't have a way to wait for all promises to resolve and return an array of text promises that can later be used with expect().
EDIT: explicitly mentioned protractor/jasmine.