Skip to content

integration_test missing FlutterDriver.waitFor support #88765

@creativecreatorormaybenot

Description

Use case

In previous integration tests for my Flutter apps, a crucial method was FlutterDriver.waitFor as it allowed the app to load up something before performing the actual test case.

With the migration to the integration_test package, this is not possible anymore. We cannot access FlutterDriver.waitFor anymore and there is no analog in the WidgetTester class.


The doc actually states:

Instead of calling driver.wait* API, use WidgetTester.pumpAndSettle() or equivalent methods.

However, this is not actually feasible.

Why there are no equivalent methods

Let us use the example of a loading screen for an app.

  • WidgetTester.pumpAndSettle() will not work at all if there is a static screen that will be replaced after some loading as it only waits for no frames being scheduled but simply cannot wait for any loading.
  • WidgetTester.pumpAndSettle(const Duration(seconds: 2)) as an example also does not work because loading will differ based on network speed, device speed, etc.

Proposal

The FlutterDriver.wait* methods should be introduced to WidgetTester. Thinking about it, the same methods should also be useful for regular widget tests anyway.
Furthermore, it is a regression to not have these. I can in fact not even migrate my old flutter_driver tests to integration_test.

Workaround

One workaround I found was writing my own waitFor function:

Future<void> waitFor(WidgetTester tester, Finder finder) async {
  do {
    await tester.pumpAndSettle();
    await Future.delayed(const Duration(milliseconds: 100));
  } while (finder.evaluate().isEmpty);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: tests"flutter test", flutter_test, or one of our testsc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: integration_testThe flutter/packages/integration_test pluginframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions