Skip to content

Upgrading bunit to 1.2.49 causes tests to fail #474

Answered by egil
robalexclark asked this question in Q&A
Discussion options

You must be logged in to vote

hi @robalexclark

The previous version of bUnit had a bug where it swallowed an error from the Blazor renderer, when an event handler that was previously attached to an element had been disposed.

I am guessing you have something in your component under test that does some work asynchronously, perhaps SelectedAnimalChanged, that causes a render after the work is done, e.g. by calling StateHasChanged. Since you are not awaiting the InvokeAsync operation, you effectively have a race condition between the code running in the test thread and the re-rendering of your CUT in the renderer.

Try this:

public async Task DocumentsGrid_DeleteButton()
{
      InsertTestData(Services.GetService<IDbContex…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@robalexclark
Comment options

@egil
Comment options

egil Aug 10, 2021
Maintainer

Answer selected by egil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants