Skip to content
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

_DeepMatcher should use describeMismatch instead of describe #77

Open
leonsenft opened this issue Apr 17, 2018 · 0 comments
Open

_DeepMatcher should use describeMismatch instead of describe #77

leonsenft opened this issue Apr 17, 2018 · 0 comments

Comments

@leonsenft
Copy link

Currently when _DeepMatcher encounters a Matcher nested within a collection and the match fails, it uses the describe method to describe the mismatch rather than the describeMismatch method.

This is best demonstrated with an example. Consider the following expectation.

expect('foo', hasLength(4));

It fails with the following message which we can all agree is quite helpful.

  Expected: an object with length of <4>
    Actual: 'foo'
     Which: has length of <3>

Meanwhile, observe what happens when we nest the value and matcher in a collection.

expect(['foo'], [hasLength(4)]);

Current output

  Expected: [<an object with length of <4>>]
    Actual: ['foo']
     Which: does not match an object with length of <4> at location [0]

While the message here is alright, it's not quite as good as before, and it's not useful if the actual value's toString() doesn't make it clear why it didn't match.

Desired output

  Expected: [<an object with length of <4>>]
    Actual: ['foo']
     Which: has length of <3> at location [0]

The ideal output would be akin to that of the non-nested expectation, making use of the expected matcher's describeMismatch method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant