platform/packages/mock_request
2021-03-21 09:37:54 +08:00
..
example Added mock_request and updated to 2.0.0 2021-03-20 10:33:34 +08:00
lib Fixed null safety 2021-03-21 09:37:54 +08:00
test Added mock_request and updated to 2.0.0 2021-03-20 10:33:34 +08:00
.gitignore Added merge_map and mock_request packages 2021-03-19 07:10:19 +08:00
.travis.yml Added merge_map and mock_request packages 2021-03-19 07:10:19 +08:00
analysis_options.yaml Added merge_map and mock_request packages 2021-03-19 07:10:19 +08:00
CHANGELOG.md Added merge_map and mock_request packages 2021-03-19 07:10:19 +08:00
LICENSE Added merge_map and mock_request packages 2021-03-19 07:10:19 +08:00
pubspec.yaml Added mock_request and updated to 2.0.0 2021-03-20 10:33:34 +08:00
README.md Added merge_map and mock_request packages 2021-03-19 07:10:19 +08:00

mock_request

Pub build status

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 testing Angel applications smoother, but works with any Dart-based server. :)

Usage

var rq = new 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 tests.