-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Description
I have noticed that only the first element which is passed to the expect function is tested for the expectation. Example:
it('should fail', function () {
var divs = $('<div title="a"></div><div title="b"></div>');
expect(divs).to.have.attr('title', 'a');
});This test does not fail because only the first div is tested. Since jQuery usually performs operations for every selected element, this was surprise for me.
I don't think the current behaviour should be changed because otherwise it could happen that tests, which fail at the moment because an empty jQuery is passed to expect() would suddenly succeed. However, I think it would be convenient to introduce the each keyword which performs the expectation for every given element. Example:
it('should fail', function () {
var divs = $('<div title="a"></div><div title="b"></div>');
expect(divs).each.to.have.attr('title', 'a');
});What do you think?
Metadata
Metadata
Assignees
Labels
No labels