routed_testing 0.4.1 copy "routed_testing: ^0.4.1" to clipboard
routed_testing: ^0.4.1 copied to clipboard

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

example/example.dart

import 'package:routed_core/routed_core.dart';
import 'package:routed_testing/routed_testing.dart';
import 'package:server_testing/server_testing.dart';

Future<void> main() async {
  final engine = Engine()
    ..get('/hello', (EngineContext ctx) {
      ctx.string('world');
    });

  final handler = RoutedRequestHandler(engine);

  // Standalone test using serverTest.
  serverTest('GET /hello returns world', (client, h) async {
    final response = await client.get('/hello');
    response.assertStatus(200).assertBodyContains('world');
  }, handler: handler);

  // Grouped tests using engineGroup — shares an engine across tests.
  engineGroup(
    'hello endpoint',
    engine: engine,
    define: (engine, client, engineTest) {
      engineTest('returns world', (engine, client) async {
        final response = await client.get('/hello');
        response.assertStatus(200).assertBodyContains('world');
      });

      engineTest('returns 404 for unknown path', (engine, client) async {
        final response = await client.get('/unknown');
        response.assertStatus(404);
      });
    },
  );
}
0
likes
160
points
287
downloads

Documentation

API reference

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_core, server_testing, test

More

Packages that depend on routed_testing