You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So the issue that I think we're trying to solve here is the fact that matchers recurse and you may not want everything to be a type matcher. We can actually achieve this through the equals matcher that essentially resets the cascading matching rules on that value (and any children):
So you could do this:
body: Matchers.like({
"foo": "bar",
"baz:" equals("bat") // <- this can be any JSON type, and may also be deeply nested
})
The equals matcher can be used anywhere deep in the JSON object, so that would help with cases where you have nested values that must be exact matches.
Checklist
Feature description
Add a matcher that spreads an object and does a
like
on each property, and add a matcher that is restricted to an exact string.Use case
Sometimes you want to wrap most (but not all) of an object in a
Matchers.like()
call, for example where you care about an exact string for type.On slack, Chris asked if it was possible to do:
Sadly, it isn't. However, you can do:
But, maybe we can make that nicer. Suggested options:
and
The text was updated successfully, but these errors were encountered: