Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency bunit to 1.36.0 #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Sep 25, 2022

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
bunit (source) 1.0.0-beta-11 -> 1.36.0 age adoption passing confidence

Release Notes

bUnit-dev/bUnit (bunit)

v1.36.0

Added
  • Bumped .NET 9 version dependencies to stable packages.

v1.35.3

Added
  • Extension packages (bunit.generators and bunit.web.query) are flagged as stable.

v1.34.0

Fixed

v1.33.3

Added
  • bunit.generators respect parameters from the base class.
  • Supports components using constructor injection in net9.0.
Fixed
  • Use latest System.Text.Json due to CVE in 8.0.4.

v1.32.7

Fixed
  • Ensure that a check in WaitForAssertion and 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.3

Fixed
  • UploadFile should only throw an exception when the file size exceeds the maximum allowed size. Reported by @​candritzky. Fixed by @​linkdotnet.

v1.30.3

Fixed

v1.29.5

Fixed
  • CI build changes to force running verification on x64 based AMD CPUs.

v1.28.9

Fixed
  • bUnit's built-in HTML parser did not correctly parse full HTML documents that included a <!DOCTYPE html> as the first element. Fixed by @​egil.
  • @formname directive led to an InvalidOperationException when used on a form element. Reported by @​suzu2469 in #​1438.
    Fixed by @​egil/@​linkdotnet.
Changed
  • NavigationManager is again registered as a singleton instead of scoped.

v1.27.17

Added
  • Support for IKeyedServiceProvider in net8.0. Reported by @​ViRuSTriNiTy. By @​linkdotnet.
  • Support for 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

v1.26.64

Changed
  • Upgraded AngleSharp to 1.0.7. Info: The usage of AngleSharpWrappers is not needed anymore. Any usage of Unwrap should not be needed anymore.
Fixed
  • When the TestContext was disposed, the Blazor Renderer itself didn't dispose components under test. By @​linkdotnet.
  • When navigating, the HistoryEntryState on NavigationManager will be populated. By @​linkdotnet.
Added
  • New overloads for IRenderedFragmentBase.InvokeAsync that allow retrieving the work item's return value. By @​jcparkyn.

v1.25.3

  • Upgrade all .NET 8 preview dependencies to .NET 8 stable.

v1.24.10

Fixed
  • When the TestContext was 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 the TestRenderer could 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 IAsyncDisposable is 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 oncancel and onclose event, that was introduced with .NET 8.

v1.23.9

Fixed
  • If the renderer was not idle when calling 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.0 support
  • Increased timeout of WaitForAssertion to infinite when a debugger is attached. By @​linkdotnet.
Fixed
  • AngleSharp IElement extension methods do not work with IRenderedFragment.Find. Reported by a2er. Fixed by @​linkdotnet.

v1.22.19

Added
  • Update bunit templates to support the target framework version of the project. By @​linkdotnet.
Fixed
  • Calling MarkupMatches(RenderFragment) from a lambda passed to e.g. WaitForAssertion could 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.9

Fixed
  • Allow using 3rd party IComponentActivator at the same time as component factories. By @​egil. Reported by BenSchoen in #​1129.

  • Calling IRenderedComponent.Render() or IRenderedComponent.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.8

Added
  • Added static DefaultWaitTimeout property to TestContext to enable overriding the default timeout of "wait for" methods like WaitForAssertion from 1 second to something else. By @​egil.
Fixed
  • TestRenderer throws ObjectDisposedException if 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.14

Fixed
Changed
  • Changed test renderer such that updates to rendered components markup happen in the same synchronization context as the test framework is using (if any), if any, to avoid memory race conditions. By @​egil.

v1.18.4

Fixed
  • Some characters where not properly escaped. Reported by @​pwhe23. Fixed by @​linkdotnet.
  • Clicking a submit button or submit input element inside a form, submits the form, if the submit button or submit input element does not have the @onclick:preventDefault attribute set. Reported by @​linkdotnet. Fixed by @​egil.

v1.17.2

  • Submit buttons and input fields now no longer cause a form submit when they have the @onclick:preventDefault attribute. By @​JelleHissink.

v1.16.2

  • Changed semantic comparer to handle elements parsed outside their proper context, e.g. an <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.5

  • Upgrade AngleSharp.Diffing to 0.17.1.

v1.14.4

Added
  • Added IMemoryCache by default to the Services container. By @​linkdotnet.
Fixed
  • Added support in FakeNavigationManager to handle umlauts.
  • Fixed a bug where attribute values did not get escaped. Reported by @​brettwinters. Fixed by @​linkdotnet.

v1.13.5

This release contains a bunch of small tweaks and fixes.

v1.12.6

Fixed

v1.11.7

Added
  • Added the StateFromJson method to the NavigationHistory type, to make it easy to deserialize navigation state stored as JSON during a call to NavigationManager.NavigateTo, e.g. as seen with the new InteractiveRequestOptions type available in .NET 7. By @​linkdotnet and @​egil.

v1.10.14

Added
  • Added new test double FakeWebAssemblyHostEnvironment that implements IWebAssemblyHostEnvironment. By @​KristofferStrube.

  • Added Bind method to parameter builder that makes it easier to emulate the @bind-Value syntax in C#-based tests.

        When writing tests in razor files, the `@bind-` directive can be directly applied like this:
    
    <MyComponent @&#8203;bind-Value="myParam"></MyComponent>
        The same expression in C# syntax is more verbose like this:
    
    RenderComponent<MyComponent>(ps => ps
      .Add(c => c.Value, value)
      .Add(c => c.ValueChanged, newValue => value = newValue)
      .Add(c => c.ValueExpression, () => value));
        With the new `Bind` method this can be done in one method:
    
    RenderComponent<MyComponent>(ps => ps
      .Bind(c => c.Value, value, newValue => value = newValue, () => value));
        By [@&#8203;linkdotnet](https://redirect.github.com/linkdotnet) and [@&#8203;egil](https://redirect.github.com/egil).
    
  • Added support for NavigationLock, which allows user code to intercept and prevent navigation. By @​linkdotnet and @​egil.

Fixed
  • JSInterop.VerifyInvoke reported the wrong number of actual invocations of a given identifier. Reported by @​otori. Fixed by @​linkdotnet.

v1.9.8

Changed
  • WaitForAssertion method 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 / WaitForAssertion and FindComponents, 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.15

Added
Changed
  • Htmlizer uses StringBuilder instead of List<string> to reduce allocations and improve render speed. By @​linkdotnet.
Fixes
  • TestServiceProvider now implements IAsyncDisposable. This means TestContext.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.

        To await the disposal of async services registered in the `TestContext.Services` container, do the following:
    
    1. Create a new type that derives from TestContext and which implement IAsyncDisposable.

    2. In the DisposeAsync() method, call Services.DisposeAsync().

    3. Override the Dispose and have it only call Services.Dispose().

      Reported by @​vedion and fixed by @​egil.

v1.7.7

Added
  • Added method SetAuthenticationType to TestAuthorizationContext to allow for custom authentication type checks. By @​TimPurdum.

  • Added DisposeComponents to TestContextBase. It will dispose and remove all components rendered by the TestContextBase. 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.NavigateTo could lead to exceptions when navigating to external url's. Reported by @​TDroogers. Fixed by @​linkdotnet.

v1.6.4

A quick minor release that primiarily fixes a regression in 1.5.12.

Fixed
  • ClickAsync could lead to bubbling exceptions from GetDispatchEventTasks even though they should be handled. Reported by @​aguacongas. Fixed by @​linkdotnet.
  • Added more non bubbling events to bUnit so it behaves closer to the HTML specification. @​linkdotnet.

v1.5.12

This 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
  • Added FakeSignOutSessionStateManage type in Blazor, that makes it easy to test components that use the SignOutSessionStateManage type. By @​linkdotnet.
  • Added a validation to AddChildContent method in ComponentParameterCollectionBuilder that will throw an exception if the component's ChildContent is a generic type. By @​denisekart.
  • Added more optional arguments for Click and DoubleClick extensions which were introduced in .NET 5 and .NET 6. By @​linkdotnet.
  • Added template support for Nunit and MSTest unit test frameworks. By @​denisekart.
Fixed
  • Changed GetDispatchEventTasks for bubbling events such that handled exceptions are not rethrown later from the WaitFor... helpers methods. Reported by @​AndrewStrickland. Fixed by @​linkdotnet

v1.4.15

This release reintroduces Stub<TComponent> and related back into the main library, so the "preview" library bunit.web.mock is 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
  • Add ComponentFactories extensions method that makes it easy to register an instance of a replacement component. By @​egil.
  • Add ability to pass ServiceProviderOptions to TestServiceProvider through property to allow users to customize the service provider. By @​rodolfograve.
Fixed
  • Changed SetParametersAndRender such that it rethrows any exceptions thrown by the component under tests SetParametersAsync method. Thanks to @​bonsall for reporting the issue. Fixed by @​egil.
  • onclick on a button inside a form will raise the onsubmit event for the form itself. Reported by [@​egil]. Fixed by @​linkdotnet.
  • Only forms are allowed to have a onsubmit event handler. When onsubmit is invoked from a non-form element results in an exception. Fixed by @​linkdotnet.

v1.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:

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 method VerifyFocusOnNavigateInvoke on bUnit's JSInterop that allow you to verify that <FocusOnNavigate> has set focus on an element during render. For example, to verify that h1 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 [@&#8203;egil](https://redirect.github.com/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 the FakeNavigationManager. 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 and WaitForElements methods. These makes it possible to wait for one or more elements to appear in the DOM before continuing a test, similar to how WaitForAssertion allows you to wait for an assertion to pass, or WaitForState allows you to wait for a predicate to pass. By @​egil.

Changed
  • Added automatic conversion of values (types) passed to Change() and Input() event trigger methods. This means that e.g. a DateTime passed to Change() is automatically converted to a string format that Blazor expects. By @​egil.
Fixed
  • The Click and DoubleClick extension methods now set the MouseEventArgs.Detail property to 1 and 2 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 on ElementReference and <FocusOnNavigate> js handler return completed Task. 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.49

Added

List of added functionality in this release.

  • Added more extensions methods to MarkupMatchesAssertExtensions to allow asserting with MarkupMatches on IEnumerable and IElement. By @​jgoday.

  • Added BunitErrorBoundaryLogger implementation of IErrorBoundaryLogger (needed for Blazor's ErrorBoundary component in .NET 6.0). By @​jgoday.

  • Added ComponentFactories property to the TestContextBase type. The ComponentFactories property is a ComponentFactoryCollection type that contains IComponentFactory types. 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>() to IRenderedFragement. Use it to check if the rendered fragment contains a component of type TComponent. Added by @​egil.

  • Added AddStub and Add extension methods to ComponentFactories that 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.5

Added
  • 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.16

The 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 SourceFileFinder library, 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.

        The new package `bunit.web.testcomponents` is provided as is, without expectation of further development or enhancements. If you are using the test components currently for writing tests, it will continue to work for you. If you are starting a new project, or have few of these tests, consider switching to the "inline render fragments" style.
      
        Here is a quick comparison of the styles, using a very simple component.
      
        First, the test component style:
      
      @&#8203;inherits TestComponentBase
      
      <Fixture Test="HelloWorldComponentRendersCorrectly">
        <ComponentUnderTest>
          <HelloWorld />
        </ComponentUnderTest>
      
        @&#8203;code
        {
          void HelloWorldComponentRendersCorrectly(Fixture fixture)
          {
            // Act
            var cut = fixture.GetComponentUnderTest<HelloWorld>();
      
            // Assert
            cut.MarkupMatches("<h1>Hello world from Blazor</h1>");
          }
        }
      </Fixture>
      
      <SnapshotTest Description="HelloWorld component renders correctly">
        <TestInput>
          <HelloWorld />
        </TestInput>
        <ExpectedOutput>
          <h1>Hello world from Blazor</h1>
        </ExpectedOutput>
      </SnapshotTest>
        The a single test in "inline render fragments" style covers both cases:
      
            @&#8203;inherits TestContext
            @&#8203;code {
              [Fact]
              public void HelloWorldComponentRendersCorrectly()
              {
                // Act
                var cut = Render(@&#8203;<HelloWorld />);
      
                // Assert
                cut.MarkupMatches(@&#8203;<h1>Hello world from Blazor</h1>);
              }
            }
      
        To make the snapshot test scenario even more compact, consider putting all code in one line, e.g. `Render(@&#8203;<HelloWorld />).MarkupMatches(@&#8203;<h1>Hello world from Blazor</h1>);`.
      
        For a more complete snapshot testing experience, I recommend looking at Simon Cropp's [Verify](https://redirect.github.com/VerifyTests) library, in particular the [Verify.Blazor extension to bUnit](https://redirect.github.com/VerifyTests/Verify.Blazor#verifybunit). Verify comes with all the features you expect from a snapshot testing library.
      
Removed

List of now removed features.

  • The AddXunitLogger method, which provided support for capturing ILogger messages and passing them to xUnit's ITestOutputHelper, 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:

    1. Add the following packages to your test project: Serilog, Serilog.Extensions.Logging, and Serilog.Sinks.XUnit.

    2. Add the following class/extension method to your test project (which replicates the signature of the removed AddXunitLogger method):

      using Microsoft.Extensions.DependencyInjection;
      using Microsoft.Extensions.Logging;
      using Serilog;
      using Serilog.Events;
      using Xunit.Abstractions;
      
      namespace Bunit
      {
      	public static class ServiceCollectionLoggingExtensions
      	{
      		public static IServiceCollection AddXunitLogger(this IServiceCollection services, ITestOutputHelper outputHelper)
      		{
      			var serilogLogger = new LoggerConfiguration()
      				.MinimumLevel.Verbose()
      				.WriteTo.TestOutput(outputHelper, LogEventLevel.Verbose)
      				.CreateLogger();
      
      			services.AddSingleton<ILoggerFactory>(new LoggerFactory().AddSerilog(serilogLogger, dispose: true));
      			services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
      
      			return services;
      		}
      	}
      }
  • The bunit.xunit package has been removed, since it is no longer needed (there is no code left in it).

v1.0.0-preview-02

The 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 the TestServiceProvider, available through the Services property on a TestContext. 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.UnhandledException property that returns a Task<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 the OnInitializedAsync method, the exception will not break the test, because it happens on another thread. To have a test fail in this scenario, you can await the UnhandledException property on the TestContext.Renderer property, e.g.:

    using var ctx = new TestContext();
    
    var cut = ctx.RenderComponent<ComponentThatThrowsDuringAsyncOperation>();
    
    Task<Exception?> waitTimeout = Task.Delay(500).ContinueWith(_ => Task.FromResult<Exception?>(null)).Unwrap();
    Exception? unhandledException = await Task.WhenAny<Exception?>(Renderer.UnhandledException, waitTimeout).Unwrap();
    
    Assert.Null(unhandledException);
        In this example, we await any unhandled exceptions from the renderer, or our wait timeout. The `waitTimeout` ensures that we will not wait forever, in case no unhandled exception is thrown.
    
        NOTE, a better approach is to use the `WaitForState` or `WaitForAssertion` methods, which now also throws unhandled exceptions. Using them, you do not need to set up a wait timeout explicitly.
    
        By [@&#8203;egil](https://redirect.github.com/egil) in [#&#8203;344](https://redirect.github.com/egil/bUnit/issues/344).
    
  • Added a simple fake navigation manager, which is registered by default in bUnit's service provider. When the fake navigation manager's NavigateTo method is called, it does two things:

    1. Set the Uri property to the URI passed to the NavigateTo method (with the URI normalized to an absolute URI).

    2. Raise the LocationChanged event with the URI passed to the NavigateTo method.

      Lets look at an example: To verify that the <GoesToFooOnInit> component below calls the NavigationManager.NavigateTo method with the expected value, do the following:

      <GoesToFooOnInit> component:

      @&#8203;inject NavigationManager NavMan
      @&#8203;code {
        protected override void OnInitialized()
        {
          NavMan.NavigateTo("foo");
        }
      }

      Test code:

      // Arrange
      using var ctx = new TestContext();
      var navMan = ctx.Services.GetRequiredService<NavigationManager>();
      
      // Act
      var cut = ctx.RenderComponent<GoesToFooOnInit>();
      
      // Assert
      Assert.Equal($"{navMan.BaseUri}foo", navMan.Uri);

      Since the foo input argument is normalized to an absolute URI, we have to do the same normalization in our assertion.

      The fake navigation manager's BaseUri is set to http://localhost/, but it is not recommended to use that URL directly in your code. Instead create an assertion by getting that value from the BaseUri property, like shown in the example above.

      By @​egil in #​345.

  • Added additional bUnit JSInterop Setup methods, that makes it possible to get complete control of invocation matching for the created handler. By @​egil.

Changed

List of changes in existing functionality.

  • WaitForAssertion and WaitForState now 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 misconfigured HttpClient. 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-01

The following section list all changes in 1.0.0 preview 01.

Added

List of new features.

  • Added support for casting BUnitJSRuntime to IJSInProcessRuntime and IJSUnmarshalledRuntime. By @​KristofferStrube in #​279

  • Added support for triggering @ontoggle event handlers through a dedicated Toggle() 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 that FocusAsync has 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 using FocusAsync:

    var cut = RenderComponent<FocusingComponent>();
    
    var input = cut.Find("input");
    
    JSInterop.VerifyFocusAsyncInvoke()
      .Arguments[0] // the first argument is the ElemenetReference
      .ShouldBeElementReferenceTo(input);
        By [@&#8203;egil](https://redirect.github.com/egil) in [#&#8203;260](https://redirect.github.com/egil/bUnit/pull/260).
    
  • Added Render(RenderFragment) and Render<TComponent>(RenderFragment) methods to TestContext, as well as various overloads to the MarkupMatches methods, that also takes a RenderFragment as the expected value.

        The difference between the generic `Render` method and the non-generic one is that the generic returns an `IRenderedComponent<TComponent>`, whereas the non-generic one returns a `IRenderedFragment`.
    
        Calling `Render<TComponent>(RenderFragent)` is equivalent to calling `Render(RenderFragment).FindComponent<TComponent>()`, e.g. it returns the first component in the render tree of type `TComponent`. This is different from the `RenderComponent<TComponent>()` method, where `TComponent` _is_ the root component of the render tree.
    
        The main usecase for these are when writing tests inside .razor files. Here the inline syntax for declaring render fragments make these methods very useful.
    
        For example, to tests the `<Counter>` page/component that is part of new Blazor apps, do the following (inside a `CounterTest.razor` file):
    
    @&#8203;code
    {
      [Fact]
      public void Counter_Increments_When_Button_Is_Clicked()
      {
        using var ctx = new TestContext();
        var cut = ctx.Render(@&#8203;<Counter />);
    
        cut.Find("button").Click();
    
        cut.Find("p").MarkupMatches(@&#8203;<p>Current count: 1</p>);
      }
    }
        Note: This example uses xUnit, but NUnit or MSTest works equally well.
    
        In addition to the new `Render` methods, a empty `BuildRenderTree` method has been added to the `TestContext` type. This makes it possible to inherit from the `TestContext` type in test components, removing the need for newing up the `TestContext` in each test.
    
        This means the test component above ends up looking like this:
    
    @&#8203;inherts TestContext
    @&#8203;code
    {
      [Fact]
      public void Counter_Increments_When_Button_Is_Clicked()
      {
        var cut = Render(@&#8203;<Counter />);
    
        cut.Find("button").Click();
    
        cut.Find("p").MarkupMatches(@&#8203;<p>Current count: 1</p>);
      }
    }
        Tip: If you have multiple test components in the same folder, you can add a `_Imports.razor` file inside it and add the `@inherits TestContext` statement in that, removing the need to add it to every test component.
    
        By [@&#8203;egil](https://redirect.github.com/egil) in [#&#8203;262](https://redirect.github.com/egil/bUnit/pull/262).
    
  • 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 various SetupModule methods available on the BunitJSInterop type available through the TestContext.JSInterop property. For example, to set up a module for handling calls to foo.js, do the following:

    using var ctx = new TestContext();
    var moduleJsInterop = ctx.JSInterop.SetupModule("foo.js");
        The returned `moduleJsInterop` is a `BunitJSInterop` type, which means all the normal `Setup<TResult>` and `SetupVoid` methods can be used to configure it to handle calls to the module from a component. For example, to configure a handler for a call to `hello` in the `foo.js` module, do the following:
    
    moduleJsInterop.SetupVoid("hello");
        By [@&#8203;egil](https://redirect.github.com/egil) in [#&#8203;288](https://redirect.github.com/egil/bUnit/pull/288).
    
  • Added support for registering services in bUnits Services collection that implements IAsyncDisposable. 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's JSInterop property. This makes it possible for first party Blazor components like the <Virtualize> component, which depend on JSInterop, to "just work" in tests.

        **Compatible with previous releases:** To get the same effect as calling `Services.AddMockJSRuntime()` in beta-11, which used to add the mock IJSRuntime in "loose" mode, you now just need to change the mode of the already on JSInterop, i.e. `ctx.JSInterop.Mode = JSRuntimeMode.Loose`.
    
        **Inspect registered handlers:** Since the new design allows registering invoke handlers in the context of the `TestContext`, you might need to get already registered handlers in your individual tests. This can be done with the `TryGetInvokeHandler()` method, that will return handler that can handle the parameters passed to it. E.g. to get a handler for a `IJSRuntime.InvokaAsync<string>("getValue")`, call `ctx.JSInterop.TryGetInvokeHandler<string>("getValue")`.
    
        Learn more [issue #&#8203;237](https://redirect.github.com/egil/bUnit/issues/237). By [@&#8203;egil](https://redirect.github.com/egil) in [#&#8203;247](https://redirect.github.com/egil/bUnit/pull/247).
    
  • The Setup<TResult>(string identifier, Func<IReadOnlyList<object?>, bool> argumentsMatcher) and SetupVoid(string identifier, Func<IReadOnlyList<object?>, bool> argumentsMatcher) methods in bUnits JSInterop/MockJSRuntime has a new second parameter, an InvocationMatcher.

        The `InvocationMatcher` type is a delegate that receives a `JSRuntimeInvoation` and returns true. The `JSRuntimeInvoation` type contains the arguments of the invocation and the identifier for the invocation. This means old code using the `Setup` and `SetupVoid` methods should be updated to use the arguments list in `JSRuntimeInvoation`, e.g., change the following call:
    
         `ctx.JSInterop.Setup<string>("foo", args => args.Count == 2)` to this:
         `ctx.JSInterop.Setup<string>("foo", invocation => invocation.Arguments.Count == 2)`.
    
        Changed added in relation to [#&#8203;240](https://redirect.github.com/egil/bUnit/issues/240) in [#&#8203;257](https://redirect.github.com/egil/bUnit/issues/257) by [@&#8203;egil](https://redirect.github.com/egil).
    
  • Changed AddTestAuthorization such that it works in Razor-based test contexts, i.e. on the Fixture and SnapshotTest types.

Removed

List of now removed features.

  • A few bUnit internal xUnit assert helper methods, the custom ShouldAllBe methods, has mistakingly been part of the bunit.xunit package. These have been removed.
Fixed

List of any bug fixes.

  • When an Add call 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. an cut.Find("button").Click() event trigger method, an ElementNotFoundException was 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-9

This 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.

  • Added InvokeAsync(Func<Task>) to RenderedComponentInvokeAsyncExtensions. By @​JeroenBos in #​151.
  • Added ITestRenderer Renderer { get ; } to IRenderedFragment to make it possible to simplify the IRenderedComponentBase<TComponent> interface. By @​JeroenBos in #​151.
  • Added support for scoped CSS to MarkupMatches and related comparer methods. By @​egil in #​195.
Changed

List of changes in existing functionality.

  • Moved InvokeAsync(), Render() and SetParametersAndRender() methods out of IRenderedComponentBase<TComponent> into extension methods. By @​JeroenBos in #​151.
  • Accessing Markup, Nodes and related methods on a rendered fragment whose underlying component has been removed from the render tree (disposed) now throws a ComponentDisposedException. By @​egil in #​184.
  • Changed bUnit's build to target both .net 5.0 and .net standard 2.1. By @​egil in #​187.
Fixed

List of any bug fixes.

  • Fixes #​175: When a component referenced in a test, e.g. through the 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-8

Here 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.

  • Authorization fakes added to make it much easier to test components that use authentication and authorization. Learn more in the Faking Blazor's Authentication and Authorization page. By @​DarthPedro in #​151.

  • Added MarkupMatches(this string actual ...) extension methods. Make it easier to compare just the text content from a DON text node with a string, while still getting the benefit of the semantic HTML comparer.

Changed

List of changes in existing functionality.

  • TestContextBase.Dispose made virtual to allow inheritor's to override it. By @​SimonCropp in #​137.
  • [Breaking change] Changed naming convention for JSMock feature and moved to new namespace, Bunit.TestDoubles.JSInterop. All classes and methods containing Js (meaning JavaScript) renamed to JS for consistency with Blazor's IJSRuntime. By @​yourilima in #​150

v1.0.0-beta-7

There are three big changes in bUnit in this release, as well as a whole host of small new features, improvements to the API, and bug fixes. The three big changes are:

  1. A splitting of the library
  2. Discovery of razor base tests, and
  3. A strongly typed way to pass parameters to a component under test.

There are also some breaking changes, which we will cover first.

NOTE: The documentation is next on the TODO list, so please bear with me while I update it to reflect all the recent changes.

Breaking changes

Due to the big restructuring of the library, there are some breaking changes, hopefully for the better.

Razor test changes

Previously, the Test and Setup methods on <Fixture> and <SnapshotTest> did not have any arguments, and the test context they represented when running, was implicitly available in the scope. This has changed with this release, such that all Test and Setup methods now receive the text context as an argument, and that should be used to call e.g. GetComponentUnderTest() on.

For example, if you have a razor based test that looks like this currently:

<Fixture Test="Test001" Setup="TestSetup">
    <ComponentUnderTest><Counter /></ComponentUnderTest>
    <Fragment>...<

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/Wndrr/DeepK8s).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMDIuNCIsInVwZGF0ZWRJblZlciI6IjM5LjExLjUiLCJ0YXJnZXRCcmFuY2giOiJtYXN0ZXIifQ==-->

@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.10.14 chore(deps): update dependency bunit to v1.12.6 Nov 20, 2022
@renovate renovate bot force-pushed the renovate/bunit-1.x branch 6 times, most recently from 26a486d to f67d156 Compare December 16, 2022 10:28
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.12.6 chore(deps): update dependency bunit to v1.13.5 Dec 16, 2022
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.13.5 Update dependency bunit to v1.13.5 Dec 17, 2022
@renovate renovate bot changed the title Update dependency bunit to v1.13.5 chore(deps): update dependency bunit to v1.13.5 Dec 17, 2022
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.13.5 chore(deps): update dependency bunit to v1.14.4 Jan 11, 2023
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.14.4 chore(deps): update dependency bunit to v1.15.5 Feb 4, 2023
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.15.5 chore(deps): update dependency bunit to v1.16.2 Feb 8, 2023
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.16.2 chore(deps): update dependency bunit to v1.17.2 Feb 22, 2023
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.17.2 chore(deps): update dependency bunit to v1.18.4 Feb 26, 2023
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.18.4 chore(deps): update dependency bunit to v1.19.14 Apr 26, 2023
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.19.14 chore(deps): update dependency bunit to v1.20.8 May 21, 2023
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.20.8 chore(deps): update dependency bunit to v1.21.9 Jul 2, 2023
@renovate renovate bot force-pushed the renovate/bunit-1.x branch 3 times, most recently from 853d3ee to f560910 Compare September 6, 2023 12:39
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.22.19 chore(deps): update dependency bunit to v1.23.9 Sep 6, 2023
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.23.9 chore(deps): update dependency bunit to v1.24.10 Oct 14, 2023
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.24.10 chore(deps): update dependency bunit to v1.25.3 Nov 14, 2023
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.25.3 chore(deps): update dependency bunit to v1.26.64 Dec 20, 2023
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.26.64 chore(deps): update dependency bunit to v1.27.17 Mar 2, 2024
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.27.17 chore(deps): update dependency bunit to v1.28.9 Apr 19, 2024
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.28.9 chore(deps): update dependency bunit to v1.29.5 Jul 7, 2024
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.29.5 chore(deps): update dependency bunit to v1.30.3 Jul 21, 2024
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.30.3 chore(deps): update dependency bunit to v1.31.3 Aug 16, 2024
@renovate renovate bot changed the title chore(deps): update dependency bunit to v1.31.3 chore(deps): update dependency bunit to 1.31.3 Aug 28, 2024
@renovate renovate bot changed the title chore(deps): update dependency bunit to 1.31.3 chore(deps): update dependency bunit to 1.32.7 Oct 4, 2024
@renovate renovate bot changed the title chore(deps): update dependency bunit to 1.32.7 chore(deps): update dependency bunit to 1.33.3 Oct 11, 2024
@renovate renovate bot changed the title chore(deps): update dependency bunit to 1.33.3 chore(deps): update dependency bunit to 1.34.0 Nov 1, 2024
@renovate renovate bot changed the title chore(deps): update dependency bunit to 1.34.0 chore(deps): update dependency bunit to 1.36.0 Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants