Created
April 5, 2021 13:00
-
-
Save tomaszpolanski/3364592b284b1c192ab7e75ea1cc43bb to your computer and use it in GitHub Desktop.
Testing time with Widget and Driver tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testWidgets('time test', (tester) async { | |
const done = Key('done'); | |
const pending = Key('pending'); | |
await tester.pumpWidget( | |
FutureBuilder( | |
future: Future<void>.delayed(const Duration(seconds: 10)), | |
builder: (context, sn) { | |
return sn.connectionState == ConnectionState.done | |
? const SizedBox(key: done) | |
: const SizedBox(key: pending); | |
}, | |
), | |
); | |
// This uses virtual time in widget tests but does not do anything in integration | |
await tester.pump(const Duration(seconds: 10)); | |
expect(find.byKey(done), findsOneWidget); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment