You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a block which executes a network access via a usecase. It waits 20 seconds for a response before the future throws a timeout and a FailureState is emitted.
I wanted to use the Clock&FakeAsync package to avoid having to wait 20 seconds in the BlocTest in the event of an error.
For "manual" Bloc tests, the entire test content can simply be wrapped:
test("Future.timeout() throws an error once the timeout is up", () async {
// Act
// Assert
unawaited(fakeAsync((async) async {
await setUpGetSyncSntity(duration: const Duration(milliseconds: 22));
final bloc = getBloc();
bloc.add(SyncStartEvent());
async.elapse(Duration(seconds: 21));
await expectLater(
bloc.stream,
emitsInOrder([
const State1(),
const TimeOutState(),
]));
// Clean up
await bloc.close();
}));
});
This advances the time by 21 seconds and simulates a timeout without actually having to wait 21 seconds.
Desired Solution
Could this option also be supported for BlocTests?
I suspect that the complete content of testBloc would have to be wrapped internally with FakeAsync and the time would have to be fast-forwarded after the call of act
The text was updated successfully, but these errors were encountered:
Description
I have a block which executes a network access via a usecase. It waits 20 seconds for a response before the future throws a timeout and a FailureState is emitted.
I wanted to use the Clock&FakeAsync package to avoid having to wait 20 seconds in the BlocTest in the event of an error.
For "manual" Bloc tests, the entire test content can simply be wrapped:
This advances the time by 21 seconds and simulates a timeout without actually having to wait 21 seconds.
Desired Solution
Could this option also be supported for BlocTests?
I suspect that the complete content of testBloc would have to be wrapped internally with
FakeAsync
and the time would have to be fast-forwarded after the call ofact
The text was updated successfully, but these errors were encountered: