I have this chunk of code that I would like to test:
if (state is abortView) {
WidgetsBinding.instance
.addPostFrameCallback((_) => Navigator.pop(context));
return Container(key: Key("ContainerToPop"),);
}
In my test I just call the view and expect that should not find anything with that key:
await tester.pumpWidget(_helper.generateApp(state: abortView));
await tester.pump();
expect(find.byKey(Key("ContainerToPop")), findsNothing);
But seems that it doesn't wait for the addPostFrameCallback
, it will just evaluate the test in the moment that the container is returned and, of course, will fail.
I'm having the same problem. Have you found a solution?
RépondreSupprimer