FlightWebSocketReplayServer class
Installs fake WebSocket connections that replay pre-recorded messages.
During a test, replace WebSocket.connect by passing install's recordedWebSocketConnect-compatible factory to your DI container, or use the FlightWebSocketReplayServer.connect method directly.
Example:
final replayServer = FlightWebSocketReplayServer(fixtures: [
WebSocketReplayFixture(
urlPattern: r'wss://api\.example\.com/ws',
serverMessages: ['{"type":"pong"}'],
),
]);
replayServer.install();
// …tests…
replayServer.uninstall();
Constructors
-
FlightWebSocketReplayServer({required List<
WebSocketReplayFixture> fixtures})
Properties
-
fixtures
→ List<
WebSocketReplayFixture> -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
connect(
String url) → Future< WebSocket> -
Finds the first fixture whose WebSocketReplayFixture.urlPattern matches
urland returns a fake WebSocket that emits the recorded messages. -
install(
) → void - Installs this instance as the global replay server.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
uninstall(
) → void - Removes the global replay server.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- current → FlightWebSocketReplayServer?
-
Returns the currently installed FlightWebSocketReplayServer, or
null.no setter