mock_request 1.0.3

  • Example
  • Installing
  • Versions
  • 63


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. :)


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.


  • Dart2 fixes
  • Apparently fix hangs that break Angel tests


import 'package:mock_request/mock_request.dart';

main() async {
  var rq = new MockHttpRequest('GET', Uri.parse('/foo'));
  await rq.close();

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  mock_request: "^1.0.3"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:mock_request/mock_request.dart';
Version Uploaded Documentation Archive
1.0.3 May 16, 2018 Go to the documentation of mock_request 1.0.3 Download mock_request 1.0.3 archive
1.0.2 Jul 2, 2017 Go to the documentation of mock_request 1.0.2 Download mock_request 1.0.2 archive
1.0.1 Jun 12, 2017 Go to the documentation of mock_request 1.0.1 Download mock_request 1.0.1 archive
1.0.0 Mar 25, 2017 Go to the documentation of mock_request 1.0.0 Download mock_request 1.0.0 archive


We analyzed this package on Jun 12, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.60.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
26 / 100
Code health derived from static analysis. [more]
99 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, other

Primary library: package:mock_request/mock_request.dart with components: io.


  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 3 hints.

    Run dartfmt to format lib/src/request.dart.

    Strong-mode analysis of lib/src/response.dart gave the following hint:

    line: 20 col: 65
    'ANY_IP_V4' is deprecated and shouldn't be used.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
charcode >=1.0.0 <2.0.0 1.1.1
dart2_constant ^1.0.0 1.0.1+dart2
Dev dependencies
angel_framework >=1.0.0-dev <2.0.0
http >=0.11.3 <0.12.0
test >=0.12.0 <0.13.0