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. :)
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.
Add this to your package's pubspec.yaml file:
dependencies: mock_request: "^1.0.2"
You can install packages from the command line:
$ pub get
$ flutter packages get
Alternatively, your editor might support
pub get or
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
|1.0.2||Jul 2, 2017|
|1.0.1||Jun 12, 2017|
|1.0.0||Mar 25, 2017|
We analyzed this package, and provided a score, details, and suggestions below.
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Detected platforms: Flutter, other
Strong-mode analysis of
lib/src/request.dartfailed with the following error:
line: 157 col: 3
Invalid override. The type of 'MockHttpRequest.asyncExpand' ('<E>((List<int>) → Stream<dynamic>) → Stream<dynamic>') isn't a subtype of 'Stream<List<int>>.asyncExpand' ('<E>((List<int>) → Stream<E>) → Stream<E>').
Changelog entries help clients to follow the progress in your code.
Fix issues reported by
dartanalyzerreported 1 error(s) and 0 warning(s).
Maintain an example.
Create a short demo in the
example/directory to show how to use this package. Common file name patterns include:
example.dartor you could also use