platform/core/mocking
2024-10-02 18:48:52 -07:00
..
example Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
lib Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
test Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
.gitignore Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
analysis_options.yaml Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
AUTHORS.md Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
CHANGELOG.md Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
LICENSE Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
pubspec.yaml Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -07:00
README.md Update: updating structure adding forked rxdart, event_bus_plus, dart_mq 2024-10-02 18:48:52 -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 Angel3 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.