Open stevanusw28 opened 3 years ago
Depends on your implementation, is there only Flushbar with duration 2 sec ? or you have some Timer(...);
in my case i added difference -1 second and add pump again after expect , and finally works
Example :
// My Snackbar
Flushbar(
title: 'Hey Ninja',
message:
'Lorem Ipsum is simply dummy text of the printing and typesetting industry',
duration: Duration(seconds: 3),
).show(context);
// Widget Test
await tester.pump(Duration(seconds: 2));
final flushbarSuccess = find.text("Hey Ninja");
expect(flushbarSuccess, findsOneWidget);
await tester.pump(Duration(seconds: 2));
gap 1 seconds means to execute matcher before flush bar is gone
@stevanusw28 Did you later find a way to test the Flushbar?
Depends on your implementation, is there only Flushbar with duration 2 sec ? or you have some Timer(...);
in my case i added difference -1 second and add pump again after expect , and finally works
Example :
// My Snackbar
Flushbar( title: 'Hey Ninja', message: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry', duration: Duration(seconds: 3), ).show(context);
// Widget Test
await tester.pump(Duration(seconds: 2)); final flushbarSuccess = find.text("Hey Ninja"); expect(flushbarSuccess, findsOneWidget); await tester.pump(Duration(seconds: 2));
gap 1 seconds means to execute matcher before flush bar is gone
This solution at least not working for me.
In my implementation, the flushbar is wrapped by WidgetsBinding.instance!.addPostFrameCallback()
. Already tried using tester.binding.scheduleFrame()
and tester.binding.scheduleWarmUpFrame()
but still not working
Hello, I try to create the widget test for the flushbar component (with duration). However, is seems there is timer that block the process like this:
Because of this, I can only expect the flushbar value just after the timer process done like this:
However, this will give the test result is failed because the
flushbarSuccess
already dismissed after 2 second. Is there any way to test the Flushbar?