moll / js-must

An assertion library for JavaScript and Node.js with a friendly BDD syntax (awesome.must.be.true()). It ships with many expressive matchers and is test runner and framework agnostic. Follows RFC 2119 with its use of MUST. Good stuff and well tested.
Other
336 stars 35 forks source link

Assert that a collection contains a value satisfying a condition #39

Open radekn opened 8 years ago

radekn commented 8 years ago

I stumbled once into a use case that seems not to be covered by must - to assert that a collection (object or array) contains a value satifsying a specific condition.

There is includes matcher, but it only checks for strict equality, so I couldn't use it. I think I ended up using Lodash to find the element, and then used exist matcher on the result. It worked well, but left me with the feeling that it would be much nicer (more concise and idiomatic) if I could do it directly with the assertion library.

Any thoughts?

moll commented 8 years ago

Hey!

You mean something like Array.prototype.some? I've thought of something like it, akin to the "middleware" thing that Must.prototype.then is — allow you to call foo.must.have.some.eql({name: "John"}) or equivalent.

radekn commented 8 years ago

Yes, having something like this would be awesome :)