Skip to content

[Question] how to catch flushbars in integration test? #126

@abdallah-odeh

Description

@abdallah-odeh

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions