-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using a Delayed Future in Widget test stops the test from completing #19
Comments
Hi @maks 👋 Are you still able to reproduce this in the latest release (v0.0.2-dev.5)? Thanks! 🙏 |
@maks any updates or can this be closed? |
@felangel sorry for the slow reply, its been a long weekend holiday here.
But unfortunately still seeing the test hang. |
@maks no worries thanks for getting back to me! Just to clarify, you said this was not a problem using I think this is expected because in a widget test you will need to use |
@felangel actually I realised when I looked again at my test that I was making it more complicated than it needed to be as I could just override my providers state and not even need to worry about the async behaviour. I still think there maybe an issue with async handling as I would have expected that FakeAsync to work with the Future I was declaring inside the FaskAsync Zone, but I'll close this for now until I get a chance to see if I can write a simple standalone test to reproduce the issue. Thanks again for looking at it! |
@felangel thanks for this fantastic package, you've saved mocking for us in the NS age!
I've have run into an issue though and I'm not sure if this is a case of my not doing something correctly but I've found that trying to use
Future.delayed()
in a mocked method in a widgetTest causes the test to hang and never complete.My code is:
where
requestCode()
calls theApiService
objectsrequestLoginCode()
method which returns a Future that completes once its network API call (in the real, nnon mocked ApiService class) completes.If I remove the
Future.delayed()
everything works as expected, BUT I want the delay in there because I'm trying to test that aCircularProgressIndicator
is displayed during the period before the Future returned byrequestLoginCode
completes.I've included the Riverpod setup code, but I don't think its relevant here.
My suspicion is this is maybe due to widgetTests running inside a FakeAsync zone though according to this SO question this approach should work (or at least used to work with mockito).
The text was updated successfully, but these errors were encountered: