mock_request 1.0.2

  • README.md
  • Installing
  • Versions
  • 51

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. Depend on it

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


dependencies:
  mock_request: "^1.0.2"

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

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
37 / 100
Health:
Code health derived from static analysis. [more]
56 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
76 / 100
Overall score:
Weighted score of the above. [more]
51

Platforms

Detected platforms: Flutter, other

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

Suggestions

  • Fix lib/src/request.dart.

    Strong-mode analysis of lib/src/request.dart failed 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>').

  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 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: main.dart, example.dart or you could also use mock_request.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
charcode >=1.0.0 <2.0.0 1.1.1
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