withFakeVooWatch<T> function

  1. @visibleForTesting
Future<T> withFakeVooWatch<T>(
  1. FutureOr<T> body(
    1. FakeVooWatchTransport fake
    )
)

Runs body with a FakeVooWatchTransport installed as the singleton's transport, then resets cleanly even if body throws.

testWidgets('does the thing', (tester) async {
  await withFakeVooWatch((fake) async {
    await VooWatchUi.instance.render(...);
    expect(fake.sentPayloads, isNotEmpty);
  });
});

Implementation

@visibleForTesting
Future<T> withFakeVooWatch<T>(FutureOr<T> Function(FakeVooWatchTransport fake) body) async {
  final fake = await installFakeVooWatch();
  try {
    return await body(fake);
  } finally {
    await resetVooWatch();
  }
}