platform/packages/core/mocking
2024-10-12 19:17:24 -07:00
..
example Refactor: changing namespace, imports, re-branding 2024-10-12 18:45:27 -07:00
lib Refactor: changing namespace, imports, re-branding 2024-10-12 18:45:27 -07:00
test Refactor: changing namespace, imports, re-branding 2024-10-12 19:17:24 -07:00
.gitignore Refactor: moved core/ into packages/ will keep core packages together 2024-10-11 19:22:40 -07:00
analysis_options.yaml Refactor: moved core/ into packages/ will keep core packages together 2024-10-11 19:22:40 -07:00
AUTHORS.md Refactor: moved core/ into packages/ will keep core packages together 2024-10-11 19:22:40 -07:00
CHANGELOG.md Refactor: changing namespace, imports, re-branding 2024-10-12 03:39:20 -07:00
LICENSE Refactor: moved core/ into packages/ will keep core packages together 2024-10-11 19:22:40 -07:00
pubspec.yaml Refactor: changing namespace, imports, re-branding 2024-10-12 18:45:27 -07:00
README.md Refactor: changing namespace, imports, re-branding 2024-10-12 18:45:27 -07:00

Mock HTTP Request

Pub Version (including pre-releases) Null Safety Discord License

Forked from mock_request to support NNBD

Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc. This makes it possible to test server-side Dart applications without having to ever bind to a port.

This package was originally designed to make testing Protevus applications smoother, but works with any Dart-based server.

Usage

var rq = MockHttpRequest('GET', Uri.parse('/foo'));
await rq.close();
await app.handleRequest(rq); // Run within your server-side application
var rs = rq.response;
expect(rs.statusCode, equals(200));
expect(await rs.transform(UTF8.decoder).join(),
    equals(JSON.encode('Hello, world!')));

More examples can be found in the included test cases.