Support Nested Matching In Custom Jest Matchers
A custom Jest matcher can use standard JavaScript operations to evaluate if the given value(s) should pass or not.
This approach alone doesn't support the power of Jest's nested matchers. Consider trying to use this like so:
This would fail, even though there is a value in there that matches any(Number)
.
Jest ships with some Jasmine utilities that you can use, just as Jest does internally, to perform nested matching:
That equals
utility knows how to compare raw values like integers, booleans, and even whole objects against nested expect
matchers.
Last updated