testing/matchers library
Custom test matchers for Chase framework.
Provides convenient matchers for testing HTTP responses.
Example:
import 'package:chase/testing/testing.dart';
import 'package:test/test.dart';
test('returns OK', () async {
final res = await client.get('/');
expect(res, isOkResponse);
expect(res, hasStatus(200));
expect(res, hasHeader('content-type', contains('json')));
});
Constants
- isClientErrorResponse → const Matcher
- Matches a response with status code in the 4xx range.
- isOkResponse → const Matcher
- Matches a response with status code in the 2xx range.
- isRedirectResponse → const Matcher
- Matches a response with status code in the 3xx range.
- isServerErrorResponse → const Matcher
- Matches a response with status code in the 5xx range.
Functions
-
hasContentType(
String type) → Matcher - Matches a response with Content-Type containing the given type.
-
hasCookie(
String name, [Object? valueMatcher]) → Matcher - Matches a response that has a Set-Cookie header with the given name.
-
hasHeader(
String name, [Object? valueMatcher]) → Matcher - Matches a response that has the specified header.
-
hasJsonPath(
String path, Object? valueMatcher) → Matcher - Matches a response body against the given matcher.
-
hasStatus(
int statusCode) → Matcher - Matches a response with the exact status code.