-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include(object) #43
Comments
Hey! Thanks for taking the time to think along! Definitely, something akin to that would be useful. Going further, I think there are a few related possible matchers:
And a few permutations of the above with shallow and deep options. Adding them all would probably get too complicated for anyone to remember. Just listing them out for completeness. Coming back to your idea, would starting with |
hey, thanks for a quick response! so, the option number 1. is how i do it at the moment, but it is a bit of a pain, plus it is not going to work with promises ( but, I like the idea of although, |
Morning! Actually I think you could use the former with promises. // When using Mocha to return a promise:
return Promise.all([
obj.must.then.have.property("foo", 1),
obj.must.then.have.property("bar", 2),
])
// When using Co to drive the generators:
yield [
obj.must.then.have.property("foo", 1),
obj.must.then.have.property("bar", 2),
] Using a single combined matcher will be shorter though. :) The existing |
makes sense. and i definitely appreciate the thoughtfulness you bring into designing the API! as for the promises I guess i meant a case that look somewhat like this one: it('returns the good data back', () => {
return request('/some/url').must.resolve.to.include({
status: 200,
body: {some: 'data'}
});
}); I'm not sure if there is a way i can have two assertions in a situation like this one. I normally just use generators or async/await and match both properties separately. But, unfortunately, not everyone is keen on using generators for an async control flow; sometimes you have to fall back to promises. And then I'd have to have an extra step, like |
Hey again! I added Would you mind giving it a quick sanity check before I cut a stable release? You can install from here with |
it looks pretty good to me, but i think matching nested params needs to be there. otherwise it will just explode unexpectedly on users |
Absolutely, a "nesting" matcher will be useful, too. While I don't find the short-is-more-lax pattern (inspired by |
come to think about it, this is a really good idea. then it makes perfect sense |
Hey @moll, I've got a feature request, if you'd be so kind
Wouldn't it be brilliant if the
#include
method would match objects agains subset objects? Like for example this:Matching the nested subsets might be a bit tricky, but worth the effort i think.
Thanks!
The text was updated successfully, but these errors were encountered: