Test CircularProgressIndicator
09:39 16 Jul 2019

I'm using the ModalProgressHud to display a spinner while it's waiting for an answer from the server. I want to test that when the user taps the button, the CircularProgressIndicator is shown. My problem is that the pumpAndSettle() will timeout because of this CircularProgressIndicator that, I think, it's constantly rebuilding itself. Any suggestion on how to test the presence of a CircularProgressIndicator? This is my test:

testWidgets(
      'Should show a CircularProgressIndicator while it tries to login', (WidgetTester tester) async {

    await (tester.pumpWidget(
             generateApp(LoginView())
          ));
    await tester.pumpAndSettle();
    await tester.tap(find.byType(FlatButton));
    await tester.pumpAndSettle();

    expect(find.byType(CircularProgressIndicator), findsOneWidget);
  });
flutter spinner loading