_DeepMatcher should use describeMismatch instead of describe
- Dominant language
- Dart
- Stars
- 536
- Forks
- 232
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 10
Description
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.
```dart
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.
```dart
expect(['foo'], [hasLength(4)]);
```
**Current output**
```
Expected: [>]
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: [>]
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.
Contributor guide
Research direction
Locate `_DeepMatcher` and trace the nested `Matcher` failure path. Reproduce the issue with `expect(['foo'], [hasLength(4)])`, then add a regression test showing that the nested mismatch reports the actual length and location [0], matching the desired output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100