0

I am using flutter test drive to test my flutter app.

All works fine, except after I wait for an element for a long time.

For example I have a login process, which takes a long time (up to 60 seconds, if the test server is busy). So I press the login button and wait for the main page to appear:

await driver.tap(find.byValueKey("login_button"));
await driver.waitUntilNoTransientCallbacks();
await driver.waitFor(find.byValueKey("main_page"), timpout: Duration(seconds: 60));

If I do this, I get: Bad state: The client closed with pending request "ext.flutter.driver". on the next command I try to execute.

If I mock the login process so that it only takes a fraction of a second, I do not get this error.

How can I tell flutter drive to be a little bit more patient with timing out?

Community
  • 1
  • 1
Nathan
  • 7,099
  • 14
  • 61
  • 125
  • Can you try by wrapping your code to wait for `main_page` with `runUnsynchronized` ? Assuming you are showing loading indicator till request is complete, it'll wait till there are no pending frames. More details here : https://api.flutter.dev/flutter/flutter_driver/FlutterDriver/runUnsynchronized.html – Darshan Dec 10 '19 at 14:37

1 Answers1

0

For me, this worked:

group('Your test', () { // your tests}, timeout: Timeout(Duration(seconds: 90)));
最白目
  • 3,505
  • 6
  • 59
  • 114