Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

In bUnit how can I wait for OnAfterRenderAsync() in the page that is my RenderComponent to complete?

$
0
0

Blazor server, .NET 8 (pre-release), I have a bUnit test where I need to wait for the OnAfterRenderAsync() in the page I am testing to complete before running tests.

So I need something like:

var renderedComponent = ctx.RenderComponent<LouisHowe.web.Pages.Account.ConfirmPhone>();renderedComponent.WaitForRenderToComplete();

Is there a way to test for this? The best I have come up with is set a value in a hidden element in the OnAfterRenderAsync() and WaitFor that element to have that value. I don't like populating elements solely for testing, but that would work.

Update: Why do I need this? Because I have two pages where I have a @ref= to a child component. And I access that to complete the initialization of the page.

I also have a page that needs to call JavaScript to get some browser settings to complete the initialization of a page.

So in those two cases, I'm not able to test everything having been initialized on the page until OnAfterRenderAsync() completes.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>