serve static method
Binds port 0 on loopback and drives with dart:io HttpClient.
Port 0 lets the OS pick a free port, so tests run in parallel without collisions.
Implementation
static Future<TestClient> serve(Router router,
{bool saveCookies = false}) async {
final server = await serving.serve(router, InternetAddress.loopbackIPv4, 0);
final origin = 'http://${server.address.host}:${server.port}';
final httpClient = HttpClient();
return TestClient._(
null,
server,
origin,
httpClient,
saveCookies: saveCookies,
);
}