1.3.42
This release includes support for .NET 6, with support for all new features in Blazor with that release. There are also a number of additions and fixes, all listed below.
Big shout out to bUnit's sponsors who helped make this release happen.
The higher tier sponsors are:
Other sponsors are:
- Hassan Rezk Habib (@hassanhabib)
- Jonny Larsson (@Garderoben)
- Domn Werner (@domn1995)
- Mladen Macanović (@stsrki)
- @ChristopheDEBOVE
Added
List of added functionality in this release.
-
Added support for writing tests of components that use the
<FocusOnNavigate>
component included in .NET 6. This includes an assertion helper methodVerifyFocusOnNavigateInvoke
on bUnit'sJSInterop
that allow you to verify that<FocusOnNavigate>
has set focus on an element during render. For example, to verify thath1
selector was used to pick an element to focus on, do:// <App /> component uses <FocusOnNavigate> var cut = RenderComponent<App>(); // Verifies that <FocusOnNavigate> called it's JavaScript function var invocation = JSInterop.VerifyFocusOnNavigateInvoke(); // Verify that the invocation of <FocusOnNavigate> JavaScript function included the "h1" as the selector Assert.Equal("h1", invocation.Arguments[0]);
By @egil.
-
Added fake version of the
PersistentComponentState
type in Blazor that makes it possible to test components that use the type. By @egil. -
Added
TriggerEvent
method to make it easier to trigger custom events. By @egil. -
Added
History
capture in theFakeNavigationManager
. By @egil. -
Added new bUnit component mocking library, available via NuGet as
bunit.web.mock
. It is currently in preview and the features/APIs of it will change! -
Added
WaitForElement
andWaitForElements
methods. These makes it possible to wait for one or more elements to appear in the DOM before continuing a test, similar to howWaitForAssertion
allows you to wait for an assertion to pass, orWaitForState
allows you to wait for a predicate to pass. By @egil.
Changed
- Added automatic conversion of values (types) passed to
Change()
andInput()
event trigger methods. This means that e.g. aDateTime
passed toChange()
is automatically converted to a string format that Blazor expects. By @egil.
Fixed
-
The
Click
andDoubleClick
extension methods now set theMouseEventArgs.Detail
property to1
and2
respectively by default, unless the user specifies something else. This makes the methods more correctly emulate how Blazor reports single or double clicks on an element in the browser. Thanks to @David-Moreira for the help troubleshooting this issue. By @egil. -
FocusAsync()
method handler onElementReference
and<FocusOnNavigate>
js handler return completedTask
. By @anddrzejb. -
Fixes handling of disposed event handlers of bubbling events. See issue #518 for details. Thanks to @David-Moreira for helping debug this issue.
-
Async event trigger methods are not public. In most circumstances you do not need to use them, but if you have a scenario where you want to check that something has not happened after an event handler was triggered, then you can use the async methods and await them to know when they are completed. See #552 for details. By @egil.