The desire for something like this was first raised in #410 as far as I can tell, but a concrete proposal was never really made there/didn't go very far.
My basic thinking is that chai already has an
all modifier, but its power seem to be very limited at the moment (to just influencing the
keys assertion). A natural extension of this would seem to be to use
all to require that an assertion holds for all items in an iterable.
I confess to not being familiar with how Chai is implemented, so I don't know if this would be possible to implement backwards compatibly (and/or if an exception would have to be made for
.all.keys to preserve the current behavior). Maybe someone with more background can weigh in on the implementation options there. Here's the syntax that I think would be nice, though:
expect([a, b, c]).to.all.equal(3);
expect([a, b, c]).to.all.satisfy(it => it > 2);
expect([a, b, c]).to.all.throw(); // etc. can imagine any assertion after the all.
expect([a, b, c]).to.all.have.all.keys('a', 'b'); // posible?
expect([a, b, c]).to.all.have.any.keys('a', 'b'); // posible?