hasJsonPath function
Matches a response body against the given matcher.
Note: This is an async matcher that requires await.
Example:
expect(await res.body, contains('Hello'));
expect(await res.body, equals('{"status":"ok"}'));
Matches a response with JSON body matching the given value or matcher.
Example:
final json = await res.json;
expect(json, hasJsonPath('user.name', 'John'));
expect(json, hasJsonPath('items', hasLength(3)));
Implementation
// Body matchers work directly with `await res.body` or `await res.json`
/// Matches a response with JSON body matching the given value or matcher.
///
/// Example:
/// ```dart
/// final json = await res.json;
/// expect(json, hasJsonPath('user.name', 'John'));
/// expect(json, hasJsonPath('items', hasLength(3)));
/// ```
Matcher hasJsonPath(String path, Object? valueMatcher) =>
_JsonPathMatcher(path, valueMatcher);