mock_request 1.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 63

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.

1.0.3

  • Dart2 fixes
  • Apparently fix hangs that break Angel tests

example/main.dart

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:


dependencies:
  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

Analysis

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

Scores

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

Platforms

Detected platforms: Flutter, other

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

Suggestions

  • 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.

Dependencies

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