another-flushbar icon indicating copy to clipboard operation
another-flushbar copied to clipboard

[Question] how to catch flushbars in integration test?

Open abdallah-odeh opened this issue 1 year ago • 0 comments

I am writing integration tests for my app and within my cases, there are cases were a A flushbar with title "Success" must appear and A flushbar with title "Error" must appear

so my Finder instance is

Finder findSuccessMessage() {
  return find.byWidgetPredicate(
      (widget) => widget is Flushbar && widget.title == 'lb_success'.tr());
}

here is my integration test code

      await tester.tap(find.byType(AppButton)); //press submit
      await tester.pumpAndSettle(); //wait until the loader goes away

      expect(findSuccessMessage(), findsOneWidget); //expect a successful result

the flushbar is indeed appear correctly, but the expect fails because it reaches that line of code when the flushbar goes away Flushbar duration is 2 seconds

and when I try to remove the await tester.pumpAndSettle(); it checks for the success message immediately after pressing the button so the API did not yet return a response!

abdallah-odeh avatar Apr 22 '24 08:04 abdallah-odeh