chore(deps): update dependency bunit to 1.40.0 #236
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
1.0.0-beta-11→1.40.0Release Notes
bUnit-dev/bUnit (bunit)
v1.40.0Fixed
v1.39.5Fixed
UriorBaseUriproperty on theFakeNavigationManagerif navigation is prevented by a handler onnet7.0or greater. Reported and fixed by @ayyron-dev in #1647FindComponentsthrows an exception, when a base and derived class was searched for. Reported by @BlueDragon709 in [#1691].v1.38.5Added
v1.37.7Added
RendererInfoandAssignedRenderMode(.net9.0).v1.36.0Added
v1.35.3Added
bunit.generatorsandbunit.web.query) are flagged as stable.v1.34.0Fixed
Microsoft.Extensions.Caching.Memory. Reported by @polajenko. Fixed by @linkdotnet.v1.33.3Added
bunit.generatorsrespect parameters from the base class.net9.0.Fixed
System.Text.Jsondue to CVE in8.0.4.v1.32.7Fixed
WaitForAssertionand related methods is always performed at once before the wait timer is started. If not, the timeout could occure before a wait-for check-condition had been attempted, causing tests to fail without reason. Fixed by @egil.v1.31.3Fixed
UploadFileshould only throw an exception when the file size exceeds the maximum allowed size. Reported by @candritzky. Fixed by @linkdotnet.v1.30.3Fixed
UploadFiledoesn't throw an exception when the file size exceeds the maximum allowed size. Reported by @MorneZaayman in #1503. Fixed by @linkdotnet.v1.29.5Fixed
Added
ComponentParameterCollectionBuilder.Addthat allow passing arguments for asynchronous callback parameters. Reported by springy76. By @Qwertyluk.v1.28.9Fixed
@formnamedirective led to anInvalidOperationExceptionwhen used on a form element. Reported by @suzu2469 in #1438.Fixed by @egil/@linkdotnet.
Changed
NavigationManageris again registered as a singleton instead of scoped.v1.27.17Added
IKeyedServiceProviderin net8.0. Reported by @ViRuSTriNiTy. By @linkdotnet.net9.0. NOTE, there is no commitment as of now to support net9.0 in bUnit v1. However. Support for net9.0 may move to a future v2 release of bUnit and be deprecated in v1. However, allowing bUnit to build and work with net9.0 previews allows our users to keep testing!Fixed
SupplyFromQueryParameterin net8.0. Reported by @aayjaychan. Fixed by @egil and @linkdotnet.v1.26.64Changed
AngleSharpWrappersis not needed anymore. Any usage ofUnwrapshould not be needed anymore.Fixed
TestContextwas disposed, the Blazor Renderer itself didn't dispose components under test. By @linkdotnet.HistoryEntryStateonNavigationManagerwill be populated. By @linkdotnet.Added
IRenderedFragmentBase.InvokeAsyncthat allow retrieving the work item's return value. By @jcparkyn.v1.25.3v1.24.10Fixed
TestContextwas disposed, it disposed of all services via the service provider. However, if there were ongoing renders happening, this could cause inconsistent state in the render tree, since theTestRenderercould try to access the service provider to instantiate components.This release changes the dispose phase such that the renderer gets disposed first, then the service provider. The disposal of any services that implement
IAsyncDisposableis now also awaited. Fixed by @egil and @linkdotnet. Reported by @BenSchoen in #1227.Added
Support for custom service provider factories (
IServiceProviderFactory<TContainerBuilder>). This enables the use of Autofac and other frameworks for dependency injection like on real-world ASP.NET Core / Blazor projects. By @inf9144.Ability to raise the
oncancelandoncloseevent, that was introduced with .NET 8.v1.23.9Fixed
SetParametersAndRender, the method could return before the parameters were set and the component under test had finished rendering. This was a regression that happened in v1.21.9. Reported by @Skintkingle in #1188. Fixed by @egil.Added
net8.0supportWaitForAssertionto infinite when a debugger is attached. By @linkdotnet.Fixed
IRenderedFragment.Find. Reported by a2er. Fixed by @linkdotnet.v1.22.19Added
Fixed
Calling
MarkupMatches(RenderFragment)from a lambda passed to e.g.WaitForAssertioncould lead to a deadlock in certain circumstances. Fixed by @linkdotnet. Reported by @uecasm in #1143.Rendering complex component hierarchies could result in a stack overflow. Fixed by @egil.. Reported by @groogiam in #1064.
Remove capturing and dispatching markup updates to test frameworks synchronization context again. This could cause deadlocks and does not have any impact on test stability. Fixed by @egil. Reported by @biohazard999 in #1144.
v1.21.9Fixed
Allow using 3rd party
IComponentActivatorat the same time as component factories. By @egil. Reported by BenSchoen in #1129.Calling
IRenderedComponent.Render()orIRenderedComponent.SetParametersAndRender()did not batch up multiple synchronous re-renders after setting parameters. This is now changed such that the method causes the component to re-render with new parameters in the same way as if a parent component had passed new parameters to it. By @egil. Reported by @Jcparkyn in #1119.v1.20.8Added
DefaultWaitTimeoutproperty toTestContextto enable overriding the default timeout of "wait for" methods likeWaitForAssertionfrom 1 second to something else. By @egil.Fixed
ObjectDisposedExceptionif any methods is accessed after it has been disposed. It will also prevent changes to the internal render tree after it has been disposed. By @egil.v1.19.14Fixed
ArgumentExceptionwithMarkupMatches. Reported by @candritzky. Fixed by @linkdotnet.Changed
v1.18.4Fixed
@onclick:preventDefaultattribute set. Reported by @linkdotnet. Fixed by @egil.v1.17.2@onclick:preventDefaultattribute. By @JelleHissink.v1.16.2<path>element parsed without being inside a<svg>element. The semantic comparer will now be able to treat those as regular elements and thus be able to compare correctly to other elements of the same type and with the same node name. By @egil.v1.15.5v1.14.4Added
IMemoryCacheby default to the Services container. By @linkdotnet.Fixed
FakeNavigationManagerto handle umlauts.v1.13.5This release contains a bunch of small tweaks and fixes.
v1.12.6Fixed
v1.11.7Added
StateFromJsonmethod to theNavigationHistorytype, to make it easy to deserialize navigation state stored as JSON during a call toNavigationManager.NavigateTo, e.g. as seen with the newInteractiveRequestOptionstype available in .NET 7. By @linkdotnet and @egil.v1.10.14Added
Added new test double
FakeWebAssemblyHostEnvironmentthat implementsIWebAssemblyHostEnvironment. By @KristofferStrube.Added
Bindmethod to parameter builder that makes it easier to emulate the@bind-Valuesyntax in C#-based tests.Added support for
NavigationLock, which allows user code to intercept and prevent navigation. By @linkdotnet and @egil.Fixed
JSInterop.VerifyInvokereported the wrong number of actual invocations of a given identifier. Reported by @otori. Fixed by @linkdotnet.v1.9.8Changed
WaitForAssertionmethod is now marked as an assertion method with the[AssertionMethod]attribute. This makes certain analyzers like SonarSource's Tests should include assertions happy. By @egil.Fixes
A race condition existed between
WaitForState/WaitForAssertionandFindComponents, if the first used the latter. Reported by @rmihael, @SviatoslavK, and @RaphaelMarcouxCTRL. Fixed by @egil and @linkdotnet.Triggering of event handlers now runs entirely inside the renderers synchronization context, avoiding race condition between elements in the DOM tree being updated by the renderer and the event triggering logic traversing the DOM tree to find event handlers to trigger. Reported by @FlukeFan. Fixed by @egil.
v1.8.15Added
InputFilecomponent. Learn more in the documentation. By @egil and @linkdotnet.Changed
HtmlizerusesStringBuilderinstead ofList<string>to reduce allocations and improve render speed. By @linkdotnet.Fixes
TestServiceProvidernow implementsIAsyncDisposable. This meansTestContext.Dispose()now calls the async disposable method as well as the non-async version on the service provider. It does however not block or await the task returned, since that can lead to deadlocks.Create a new type that derives from
TestContextand which implementIAsyncDisposable.In the
DisposeAsync()method, callServices.DisposeAsync().Override the
Disposeand have it only callServices.Dispose().Reported by @vedion and fixed by @egil.
v1.7.7Added
Added method
SetAuthenticationTypetoTestAuthorizationContextto allow for custom authentication type checks. By @TimPurdum.Added
DisposeComponentstoTestContextBase. It will dispose and remove all components rendered by theTestContextBase. By @linkdotnet.Added .NET 7 as a target framework for bUnit. By @linkdotnet.
Fixed
Fixed step by step guide for building and viewing the documentation locally. By @linkdotnet.
FakeNavigationManager.NavigateTocould lead to exceptions when navigating to external url's. Reported by @TDroogers. Fixed by @linkdotnet.v1.6.4A quick minor release that primiarily fixes a regression in 1.5.12.
Fixed
ClickAsynccould lead to bubbling exceptions fromGetDispatchEventTaskseven though they should be handled. Reported by @aguacongas. Fixed by @linkdotnet.v1.5.12This first release of 2022 includes one fix and four additions. A huge thank you to Steven Giesel (@linkdotnet) and Denis Ekart (@denisekart) for their contributions to this release.
Also a big shout out to bUnit's sponsors who helped make this release happen.
The higher tier sponsors are:
Other sponsors are:
Added
FakeSignOutSessionStateManagetype in Blazor, that makes it easy to test components that use theSignOutSessionStateManagetype. By @linkdotnet.AddChildContentmethod inComponentParameterCollectionBuilderthat will throw an exception if the component'sChildContentis a generic type. By @denisekart.ClickandDoubleClickextensions which were introduced in .NET 5 and .NET 6. By @linkdotnet.NunitandMSTestunit test frameworks. By @denisekart.Fixed
GetDispatchEventTasksfor bubbling events such that handled exceptions are not rethrown later from theWaitFor...helpers methods. Reported by @AndrewStrickland. Fixed by @linkdotnetv1.4.15This release reintroduces
Stub<TComponent>and related back into the main library, so the "preview" librarybunit.web.mockis already obsolete.A big shout out to bUnit's sponsors who helped make this release happen.
The higher tier sponsors are:
Other sponsors are:
Added
ComponentFactoriesextensions method that makes it easy to register an instance of a replacement component. By @egil.ServiceProviderOptionstoTestServiceProviderthrough property to allow users to customize the service provider. By @rodolfograve.Fixed
SetParametersAndRendersuch that it rethrows any exceptions thrown by the component under testsSetParametersAsyncmethod. Thanks to @bonsall for reporting the issue. Fixed by @egil.onclickon a button inside a form will raise theonsubmitevent for the form itself. Reported by [@egil]. Fixed by @linkdotnet.onsubmitevent handler. Whenonsubmitis invoked from a non-form element results in an exception. Fixed by @linkdotnet.v1.3.42This 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:
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 methodVerifyFocusOnNavigateInvokeon bUnit'sJSInteropthat allow you to verify that<FocusOnNavigate>has set focus on an element during render. For example, to verify thath1selector was used to pick an element to focus on, do:Added fake version of the
PersistentComponentStatetype in Blazor that makes it possible to test components that use the type. By @egil.Added
TriggerEventmethod to make it easier to trigger custom events. By @egil.Added
Historycapture 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
WaitForElementandWaitForElementsmethods. These makes it possible to wait for one or more elements to appear in the DOM before continuing a test, similar to howWaitForAssertionallows you to wait for an assertion to pass, orWaitForStateallows you to wait for a predicate to pass. By @egil.Changed
Change()andInput()event trigger methods. This means that e.g. aDateTimepassed toChange()is automatically converted to a string format that Blazor expects. By @egil.Fixed
The
ClickandDoubleClickextension methods now set theMouseEventArgs.Detailproperty to1and2respectively 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 onElementReferenceand<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.
v1.2.49Added
List of added functionality in this release.
Added more extensions methods to
MarkupMatchesAssertExtensionsto allow asserting withMarkupMatchesonIEnumerableandIElement. By @jgoday.Added
BunitErrorBoundaryLoggerimplementation ofIErrorBoundaryLogger(needed for Blazor's ErrorBoundary component in .NET 6.0). By @jgoday.Added
ComponentFactoriesproperty to theTestContextBasetype. TheComponentFactoriesproperty is aComponentFactoryCollectiontype that containsIComponentFactorytypes. These are used by bUnits component activator, whenever a component is created during testing. If no component factories is added to the collection, the standard component activator mechanism from Blazor is used. This feature makes it possible to control what components are created normally during a test, and which should be e.g. replaced by a test dummy. More info is available in issue #388.Learn more about this feature on the Controlling component instantiation page.
Added
HasComponent<TComponent>()toIRenderedFragement. Use it to check if the rendered fragment contains a component of typeTComponent. Added by @egil.Added
AddStubandAddextension methods toComponentFactoriesthat makes it easy to configure bUnit to replace components in the render tree with stubs. Both methods have overloads that allow for fine grained selection of component types to "double" during testing. Added by @egil in #400.Changed
List of changes in this release.
Updated AngleSharp and related libraries to 0.16.0. NOTE, the new version of AngleSharp includes nullable annotations, which might affect how your code compiles, if you have nullable checking enabled in your test project. By @egil.
Updated .NET 6 dependencies to preview 5. By @egil.
Fixed
List of fixes in this release.
Fixed JSInterop error message when trying to import an unconfigured module. By @jgoday in #425.
Fixed issue where a registered fall-back service provider was not made available to resolve service dependencies of components under test. Thanks to @dady8889 for the reporting the issue.
Fixed handling of escaped uri's in FakeNavigationManager. By @linkdotnet in #460.
Captured error message from event dispatcher in renderer that would previously be hidden from the user. Related to issue #399.
v1.1.5Added
All bUnit assemblies is now strong named signed.
Added .NET 6 (preview 3) as a target framework for bUnit, bUnit.core and bUnit.web.
Changed
Changed bunit.template such that created projects only reference the bUnit package. Bumped other referenced packages to latest version.
Changed TestServiceProvider to validate scopes of registered services, such that it behaves like the service provider (default IoC container) in Blazor.
v1.0.16The following section list all changes since preview 02.
Changed
List of changes in existing functionality.
BREAKING CHANGE: Writing tests using the test components
<Fixture>and<SnapshotTest>components inside .razor files has been moved to its own library,bunit.web.testcomponents. This was done for several reasons:The feature has been experimental since it was introduced, and it was introduced get a more natural way of specifying the component under test and any related markup used by test.
The feature is only supported with xUnit.
There are some issues related to the
SourceFileFinderlibrary, which is used to discover the test components.A better way of writing tests in .razor files has been added to bUnit, using "inline render fragments". This method works with all general purpose test frameworks, e.g. MSTest, NUnit, and xUnit, is more flexible, and offer less boilerplate code than the test components. The bUnit documentation has been updated with a guide to this style.
Removed
List of now removed features.
The
AddXunitLoggermethod, which provided support for capturingILoggermessages and passing them to xUnit'sITestOutputHelper, has been removed. There were no need to keep xUnit specific code around in bUnit going forward, and there are many implementations on-line that supports this feature, so having it in bUnit made little sense. One such alternative, which bUnit has adopted internally, is to use Serilog. This looks as follows:Add the following packages to your test project:
Serilog,Serilog.Extensions.Logging, andSerilog.Sinks.XUnit.Add the following class/extension method to your test project (which replicates the signature of the removed
AddXunitLoggermethod):The
bunit.xunitpackage has been removed, since it is no longer needed (there is no code left in it).v1.0.0-preview-02The following section list all changes in 1.0.0 preview 02.
The plan is to make this the last preview release of bUnit. If no big blocking bugs show up the next two weeks, a non-preview release of bUnit will be pushed out to the world.
Added
List of new features.
Added the ability to pass a "fallback
IServiceProvider" to theTestServiceProvider, available through theServicesproperty on aTestContext. The fallback service provider enables a few interesting scenarios, such as using an alternative IoC container, or automatically generating mocks of services components under test depend on. See the Injecting Services into Components Under Test page for more details on this feature. By @thopdev in #310.Added
Task<Expection> ITestRenderer.UnhandledExceptionproperty that returns aTask<Exception>that completes when the renderer captures an unhandled exception from a component under test. If a component is missing exception handling of asynchronous operations, e.g. in theOnInitializedAsyncmethod, the exception will not break the test, because it happens on another thread. To have a test fail in this scenario, you can await theUnhandledExceptionproperty on theTestContext.Rendererproperty, e.g.:Added a simple fake navigation manager, which is registered by default in bUnit's service provider. When the fake navigation manager's
NavigateTomethod is called, it does two things:Set the
Uriproperty to the URI passed to theNavigateTomethod (with the URI normalized to an absolute URI).Raise the
LocationChangedevent with the URI passed to theNavigateTomethod.Lets look at an example: To verify that the
<GoesToFooOnInit>component below calls theNavigationManager.NavigateTomethod with the expected value, do the following:<GoesToFooOnInit>component:Test code:
Since the
fooinput argument is normalized to an absolute URI, we have to do the same normalization in our assertion.The fake navigation manager's
BaseUriis set tohttp://localhost/, but it is not recommended to use that URL directly in your code. Instead create an assertion by getting that value from theBaseUriproperty, like shown in the example above.By @egil in #345.
Added additional bUnit JSInterop
Setupmethods, that makes it possible to get complete control of invocation matching for the created handler. By @egil.Changed
List of changes in existing functionality.
WaitForAssertionandWaitForStatenow throws unhandled exception caught by the renderer from a component under test. This can happen if a component is awaiting an asynchronous operation that throws, e.g. a API call using a misconfiguredHttpClient. By @egil in #310.Improvements to error message from bUnit's JSInterop when it receives an invocation that it has not been set up to handle. By @egil in #346.
Removed
List of now removed features.
Fixed
List of any bug fixes.
v1.0.0-preview-01The following section list all changes in 1.0.0 preview 01.
Added
List of new features.
Added support for casting
BUnitJSRuntimetoIJSInProcessRuntimeandIJSUnmarshalledRuntime. By @KristofferStrube in #279Added support for triggering
@ontoggleevent handlers through a dedicatedToggle()method. By @egil in #256.Added out of the box support for
<Virtualize>component. When a<Virtualize>component is used in a component under test, it's JavaScript interop-calls are faked by bUnits JSInterop, and it should result in all items being rendered immediately. By @egil in #240.Added support for components that call
ElementReference.FocusAsync. These calls are handled by the bUnits JSInterop, that also allows you to verify thatFocusAsynchas been called for a specific element. For example, if a component has rendered an<input>element, then the following code will verify that it has been focused usingFocusAsync:Added
Render(RenderFragment)andRender<TComponent>(RenderFragment)methods toTestContext, as well as various overloads to theMarkupMatchesmethods, that also takes aRenderFragmentas the expected value.Added support for
IJSRuntime.InvokeAsync<IJSObjectReference>(...)calls from components. There is now a new setup helper methods for configuring how invocations towards JS modules should be handled. This is done with the variousSetupModulemethods available on theBunitJSInteroptype available through theTestContext.JSInteropproperty. For example, to set up a module for handling calls tofoo.js, do the following:Added support for registering services in bUnits
Servicescollection that implementsIAsyncDisposable. Suggested by @jmaillet in #249.Changed
List of changes in existing functionality.
bUnit's mock IJSRuntime has been moved to an "always on" state by default, in strict mode, and is now available through
TestContext'sJSInteropproperty. This makes it possible for first party Blazor components like the<Virtualize>component, which depend on JSInterop, to "just work" in tests.The
Setup<TResult>(string identifier, Func<IReadOnlyList<object?>, bool> argumentsMatcher)andSetupVoid(string identifier, Func<IReadOnlyList<object?>, bool> argumentsMatcher)methods in bUnits JSInterop/MockJSRuntime has a new second parameter, anInvocationMatcher.Changed
AddTestAuthorizationsuch that it works in Razor-based test contexts, i.e. on theFixtureandSnapshotTesttypes.Removed
List of now removed features.
ShouldAllBemethods, has mistakingly been part of the bunit.xunit package. These have been removed.Fixed
List of any bug fixes.
When an
Addcall to the component parameter collection builder was used to select a parameter that was inherited from a base component, the builder incorrectly reported the selected property/parameter as missing on the type. Reported by @nickmuller in #250.When an element, found in the DOM tree using the
Find(), method was removed because of an event handler trigger on it, e.g. ancut.Find("button").Click()event trigger method, anElementNotFoundExceptionwas thrown. Reported by @nickmuller in #251.In the built-in fake authentication system in bUnit, roles and claims were not available in components through the a cascading parameter of type
Task<AuthenticationState>. Reported by @AFAde in #253 and fixed in #291 by @egil.v1.0.0-beta-9This release contains a couple of fixes, and adds support for .NET Preview 8 and later. There are no breaking changes in this release.
Thanks to pharry22 for submitting fixes and improvements to the documentation.
Added
List of new features.
InvokeAsync(Func<Task>)toRenderedComponentInvokeAsyncExtensions. By @JeroenBos in #151.ITestRenderer Renderer { get ; }toIRenderedFragmentto make it possible to simplify theIRenderedComponentBase<TComponent>interface. By @JeroenBos in #151.MarkupMatchesand related comparer methods. By @egil in #195.Changed
List of changes in existing functionality.
InvokeAsync(),Render()andSetParametersAndRender()methods out ofIRenderedComponentBase<TComponent>into extension methods. By @JeroenBos in #151.Markup,Nodesand related methods on a rendered fragment whose underlying component has been removed from the render tree (disposed) now throws aComponentDisposedException. By @egil in #184.Fixed
List of any bug fixes.
FindComponent()method was removed from the render tree, accessing the reference could caused bUnit to look for updates to it in the renderer, causing a exception to be thrown. By @egil in #184.v1.0.0-beta-8Here is beta-8, a small summer vacation release this time. A few needed additions, especially around testing components that use Blazor's authentication and authorization. In addition to this, a lot of documentation has been added to https://bunit.egilhansen.com/docs/getting-started/.
Added
List of new features.
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.