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
Most devs in status-mobile using the lib https://github.com/nubank/matcher-combinators are surprised by the fact that the match? directive does not match expected map instances versus actual exactly. Unless a different matcher wraps the the expected map, match? will use the embeds matcher, which ignores unspecified keys in expected. This might be so surprising that can cause devs to waste a lot of time debugging why tests are passing when they should fail, until they realize this behavior is correct and documented in the library.
Implementation
We are currently using version 3.8.8, but version 3.9.0 has a new matcher called nested-equals. So the simplest solution is to upgrade the library and use this new matcher when needed.
The default behavior of match? is useful, but it's open for debate if the default behavior is what we want or if it wouldn't be better to be more strict by default. Probably being strict will cause less headaches and surprises, so another solution on top of the upgrade is to replace the default directive match? with one that's strict by default, and then the developer would still be able to override the default matcher when they want the embeds matcher.
Problem
Most devs in
status-mobile
using the lib https://github.com/nubank/matcher-combinators are surprised by the fact that thematch?
directive does not match expected map instances versus actual exactly. Unless a different matcher wraps the the expected map,match?
will use the embeds matcher, which ignores unspecified keys in expected. This might be so surprising that can cause devs to waste a lot of time debugging why tests are passing when they should fail, until they realize this behavior is correct and documented in the library.Implementation
We are currently using version
3.8.8
, but version3.9.0
has a new matcher callednested-equals
. So the simplest solution is to upgrade the library and use this new matcher when needed.The default behavior of
match?
is useful, but it's open for debate if the default behavior is what we want or if it wouldn't be better to be more strict by default. Probably being strict will cause less headaches and surprises, so another solution on top of the upgrade is to replace the default directivematch?
with one that's strict by default, and then the developer would still be able to override the default matcher when they want the embeds matcher.Note
For the record, we have a guideline about using
match?
and why instead of=
. https://github.com/status-im/status-mobile/blob/3ce6a86e9b9dba53c25265c243183d6884bb5aca/doc/new-guidelines.md#prefer-match-over--when-comparing-data-structuresThe text was updated successfully, but these errors were encountered: