You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are observing a difference in behaviour when running BUnit tests from Visual Studio and dotnet test.
This affects calling Change("value") on InputDate and InputNumber.
These work as expected in the Visual Studio Test Explorer. However, no value appears to be set on the <input> element when run via dotnet test. This is not consistent - sometimes the tests pass / fail with no modification in between runs.
The following errors were found:
1: The value of the attribute input(0)[class] and actual attribute input(1)[class] are different.
2: The value of the attribute input(0)[value] and actual attribute input(1)[value] are different.
Actual HTML:
<input id="delivery-date" type="date" class="form-control valid" value="" >
Expected HTML:
<input id="delivery-date" type="date" class="form-control modified valid" value="2021-09-20">
Expected behavior:
Expect the value of the <input> element to be consistently set to the value specified when calling Change().
Version info:
bUnit version: 1.2.49
.NET Runtime and Blazor version: 6.0 RC1
OS type and version: Windows 10 - 19042.1165
Additional context:
We are working to identify a minimal reproduction. Any ideas on anything we can try would be appreciated.
Adding Thread.Sleep(1000) between calling Change() and MarkupMatches() appears to reduce (or possibly prevent) failure - is this timing / asynchrony related?
Hi @LordBenjamin, thanks for a well described issue.
If there is an asynchronous re-render being triggered by Change, then you might need to use WaitForAssertion, since that synchronizes between the render thread and the test thread. Learn more about it here: https://bunit.dev/docs/verification/async-assertion
Activity
egil commentedon Sep 21, 2021
Hi @LordBenjamin, thanks for a well described issue.
If there is an asynchronous re-render being triggered by
Change, then you might need to use WaitForAssertion, since that synchronizes between the render thread and the test thread. Learn more about it here: https://bunit.dev/docs/verification/async-assertionTry this and let me know how it goes.
LordBenjamin commentedon Oct 3, 2021
Thanks for the suggestion @egil.
WaitForAssertion()seems to be what we were looking for!