jsonPath method
Asserts a JSON path has the expected value.
This method is async.
Example:
await res.expect.jsonPath('user.name', 'John');
await res.expect.jsonPath('items', hasLength(3));
Implementation
Future<ResponseExpect> jsonPath(String path, Object expected) async {
final json = await _response.json;
final value = _getJsonPath(json, path);
if (expected is Matcher) {
if (!expected.matches(value, {})) {
throw ChaseTestFailure(
'JSON path "$path" with value "$value" did not match expected',
);
}
} else if (value != expected) {
throw ChaseTestFailure(
'Expected JSON path "$path" to be "$expected" but got "$value"',
);
}
return this;
}