-
Notifications
You must be signed in to change notification settings - Fork 213
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
Add some way to go into a "normal" execution mode, and then back into being controlled by fake async #2303
Comments
cc @mehmetf - I'm not sure if there are any testing issues or confusion you've seen that would be improved by this. I don't have immediate plans to start working on this and I don't know how difficult it would be. |
Doesn't this invalidate the use case for fake_async? Why use it at all? |
It wouldn't be the general behavior, it would be something you enter/exit in your test. // Some interaction with the production code using fake async
...
// now I have a little work I want to do in the test body.
fakeAsync.useNormalEventLoop();
await doSomething();
await doMoreStuff();
fakeAsync.useControlledEventLoop();
// More normal use of fake async So most of the time It would also mean that |
Ah. That's currently possible in flutter_test via
|
Oh, I like that API too. I didn't think we would get past that outer We could add |
That would be another interesting API to investigate. In particular it would be nice if the var f = Future.value(1); // Created in the FakeAsync zone.
await tester.runAsync(() {
await f; // stuck here forever.
}); |
Yep. That was the original motivation why I was looking into running setup/teardown in consistent zones.
This doesn't even have |
@natebosch Any update on this? |
No, this isn't something we are actively pursuing. This is something we could push on if we find more concrete use cases and have a solid idea of the design that addresses them. |
The case explained in the comment from @natebosch is very difficult to track down. |
This stuff is quite confusing, is it why my test is timing out? It seems like when I start my mock server in setUp, my test times out and doesn't even seem to start running. If I create it in-line inside the group, it works fine
|
How about |
There is any solution to this issue? |
Yes but @natebosch I am wondering if the limitations of |
This looks promising. I wonder if this combined with a lint to avoid |
What's the issue with 'runAsync'? |
It leads to flaky tests, its docs explains a bit why it should be avoided if possible. |
Sometimes it's nice to be able to have a little block of
async/await
code in your test.await
is very tricky to use in a fake async zone since it will never complete until eitherelapse
orflushMicrotasks
is called, but you can't get past it until then.It might be possible to add some way that at least the event loop and microtask queue still operate normally. Making timers fire would likely not be possible, but also doesn't impact the
await
case.The text was updated successfully, but these errors were encountered: