Why isn't there a WaitForSettledDown()? #1278
-
Hi all; I'm sure this has been asked before, but I couldn't find it. Why isn't there a call to I'm asking in the context of #1276 where I need to set the value in an But back to the general question - why isn't there a And you all are clearly smart and know your stuff. So there's probably a good reason this can't be done. But if so, could you explain why? Because that will help me understand what I'm working against as I write my tests and use thanks - dave |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Consider this scenario. You have a component with a Task.Delay(1 second) in an OnInitialized. We cannot know that. We do know when the renderer is idle, but that may change at any moment based on the components under test. We simply don't know. Now, if you have a component state you want to wait for to happen, but it's not externally observable from either the markup or object state, or dependency state, you may be trying to write a test that is verifying implementation details about your component, which is not recommend. Tests should never be tied to or assert on implementation details. |
Beta Was this translation helpful? Give feedback.
-
The short answer to your question is that we might introduce that in the future. The Blazor team itself has functions like To put it simply: It isn't always easy to find out, that stuff is going on or better that stuff will go on. Personally in my tests I try to fake out all asynchronous stuff as much as possible. An external call can be mocked most of the times (for example if you put it into a separate service) and the mocked service can use something like |
Beta Was this translation helpful? Give feedback.
Yes. And yes Tasks are still there, but they are directly completed from the get-go - therefore the Blazor renderer does everything synchronously. As you mentioned in the other thread - that would be an implementation detail.