having method
Returns a new TypeMatcher that validates the existing type as well as
a specific feature
of the object with the provided matcher
.
Provides a human-readable description
of the feature
to make debugging
failures easier.
/// Validates that the object is a [RangeError] with a message containing
/// the string 'details' and `start` and `end` properties that are `null`.
final _rangeMatcher = isRangeError
.having((e) => e.message, 'message', contains('details'))
.having((e) => e.start, 'start', isNull)
.having((e) => e.end, 'end', isNull);
Implementation
@useResult
TypeMatcher<T> having(
Object? Function(T) feature, String description, dynamic matcher) =>
HavingMatcher(this, description, feature, matcher);