routed_testing 0.2.1+1 copy "routed_testing: ^0.2.1+1" to clipboard
routed_testing: ^0.2.1+1 copied to clipboard

Routed-specific testing utilities that extend server_testing for integration tests.

routed_testing #

Pub Version CI License Sponsor

Routed-specific helpers built on top of server_testing. It wires the Routed engine into the transport abstractions so you can issue HTTP requests against an in-memory engine or launch an ephemeral server without writing glue code.

Features #

  • Drop-in RequestHandlerRoutedRequestHandler bootstraps an Engine and connects it to the testing transports.
  • In-memory & real sockets – flip between TransportMode.inMemory and TransportMode.ephemeralServer without changing your test body.
  • Property helpers – reuse TestClient with property_testing to stress routing, params, or middleware stacks.

Install #

dev_dependencies:
  routed_testing: ^0.2.1
  server_testing: ^0.2.0
  routed: ^0.2.0
  test: ^1.26.0

dart pub add --dev routed_testing server_testing routed will update your pubspec automatically.

Usage #

import 'dart:io';

import 'package:routed/routed.dart';
import 'package:routed_testing/routed_testing.dart';
import 'package:server_testing/server_testing.dart';
import 'package:test/test.dart';

void main() {
  test('GET /ping', () async {
    final engine = Engine()..get('/ping', (ctx) => ctx.text('pong'));
    await engine.initialize();
    final handler = RoutedRequestHandler(engine);
    final client = TestClient.inMemory(handler);

    final response = await client.get('/ping');
    response.assertStatus(HttpStatus.ok).assertBodyContains('pong');

    await client.close();
    await handler.close();
    await engine.close();
  });
}

See test/ for more patterns, including property-based coverage of route parameters across transports.

Funding #

Help sustain the Routed ecosystem by sponsoring @kingwill101.***

0
likes
150
points
5
downloads

Publisher

unverified uploader

Weekly Downloads

Routed-specific testing utilities that extend server_testing for integration tests.

Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

www.buymeacoffee.com

License

MIT (license)

Dependencies

meta, routed, server_testing, test

More

Packages that depend on routed_testing