-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Labels
a: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsa: typographyText rendering, possibly libtxtText rendering, possibly libtxtt: flutter driver"flutter driver", flutter_drive, or a driver test"flutter driver", flutter_drive, or a driver testtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.
Description
[✓] Flutter (Channel beta, v1.14.6, on Mac OS X 10.15.3 19D76, locale en-TH)
I am experiencing a flaky test.
await driver.tap(find.byValueKey('first-name-field'));
await driver.enterText('');
// await Future.delayed(Duration(milliseconds: 17), () {});
expect(
await driver.getText(find.byValueKey('first-name-error')),
equals('Field can't be empty.'),
);
await driver.enterText('$#@');
// await Future.delayed(Duration(milliseconds: 17), () {});
expect(
await driver.getText(find.byValueKey('first-name-error')),
equals('Field contains unsupported characters.'),
);
await driver.enterText('Chris');
// await Future.delayed(Duration(milliseconds: 17), () {});
await driver.waitForAbsent('first-name-error');
90% of the time the test succeeds, but occasionally the expectations see the previous values. These error labels are built by StreamBuilder. "onChanged" event of text field is adding events to the steam.
As you see in the commented code I attempted to add some delays - it helped a bit but tests are still flaky.
I see you have the following method:
await driver.waitFor(find.text('Field can\'t be empty.!'))
However on my screen there is more than 1 label that can have this value at the same time.
Question
Can I wait for a specific label to have the expected text?
Something like (I made up this code):
await driver.waitFor(find.byValueKey('first-name-error').text('Field can\'t be empty.!'))
nerder
Metadata
Metadata
Assignees
Labels
a: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsa: typographyText rendering, possibly libtxtText rendering, possibly libtxtt: flutter driver"flutter driver", flutter_drive, or a driver test"flutter driver", flutter_drive, or a driver testtoolAffects the "flutter" command-line tool. See also t: labels.Affects the "flutter" command-line tool. See also t: labels.