Skip to content

Instantly share code, notes, and snippets.

@tomaszpolanski
Created April 5, 2021 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaszpolanski/3364592b284b1c192ab7e75ea1cc43bb to your computer and use it in GitHub Desktop.
Save tomaszpolanski/3364592b284b1c192ab7e75ea1cc43bb to your computer and use it in GitHub Desktop.
Testing time with Widget and Driver tests
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