start method
Start the test server on a random available port.
Automatically finds an available port in the ephemeral range and starts the Supafast application. Creates an HTTP client with appropriate timeouts for testing scenarios.
Example:
final testApp = TestApp(app);
await testApp.start(); // Uses localhost
// or
await testApp.start(hostname: '127.0.0.1');
hostname The hostname to bind the server to (default: 'localhost').
Throws SocketException if no available port can be found.
Implementation
Future<void> start({String hostname = 'localhost'}) async {
_port = await _findAvailablePort();
_hostname = hostname;
// Start the app on the test port
await app.listen(_port!, hostname: hostname);
// Create HTTP client for making requests
_client = HttpClient()
..connectionTimeout = const Duration(seconds: 5)
..idleTimeout = const Duration(seconds: 30);
}