0

I have the following working e2e test code:

it('should ...', function () {
    var promise = element('#id').query(function (elements, done) {
        var children = elements.children();
        done(null, children.prevObject[0].innerHTML);
    });

    var pattern = /...some pattern.../;
    expect(promise).toMatch(pattern);
});

However, I want to return a list of data in done() and then test each element. How to do that? The angularjs's e2e document is very poor and I can't find anything useful there.

I want something like this:

it('should ...', function () {
    var promise = element('#id').query(function (elements, done) {
        var children = elements.children();
        done(null, children.prevObject);
    });

    var pattern = /...some pattern.../;
    expect(item.innerHTML in promise).toMatch(pattern);
});

Thanks in advance!

zs2020
  • 53,766
  • 29
  • 154
  • 219

1 Answers1

2

You can always loop through your array prevObject and write an expectation within the loop.

for(var i = 0; i < promise.length; i++) {
  expect(promise[i].innerHTML).toMatch(pattern);
}
Mike Pugh
  • 6,787
  • 2
  • 27
  • 25
  • Thanks. I forgot to try this. I tried forEach first and since it is undefined and I forgot this approach. I am getting old :( – zs2020 Jul 12 '13 at 17:09