Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
abdallah-odeh opened this issue Apr 22, 2024 · 0 comments
Open

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

abdallah-odeh opened this issue Apr 22, 2024 · 0 comments

Comments

@abdallah-odeh
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant