BlazorTestingLibrary 1.0.0

.NET 6.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package BlazorTestingLibrary --version 1.0.0
NuGet\Install-Package BlazorTestingLibrary -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlazorTestingLibrary" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorTestingLibrary --version 1.0.0
#r "nuget: BlazorTestingLibrary, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlazorTestingLibrary as a Cake Addin
#addin nuget:?package=BlazorTestingLibrary&version=1.0.0

// Install BlazorTestingLibrary as a Cake Tool
#tool nuget:?package=BlazorTestingLibrary&version=1.0.0


A (better?) React-like testing approach for Blazor apps. This is still a work in progress but it's useable 😃

Quickstart Example

using BlazorTestingLibrary;
using Bunit;
using FluentAssertions;
using Xunit;


public void SubmittingAValidForm()
    using var context = new TestContext();
    var component = context.RenderComponent<ExampleForm>();

    var forenameInput = component.FindByLabelText("Forename:");

    var surnameInput = component.FindByLabelText("Surname:");

    var emailInput = component.FindByLabelText("Email Address:");

    var submitButton = component.FindByText("Submit");

    component.FindByText("Your form is Submitted").Should().NotBeNull();

Search Methods


Searches for a given text string in the DOM and returns the first element that contains it. Throws if there is more than one element found or nothing is found.


Searches for a given text string in the DOM and returns all instances of elements that contain it. Throws if nothing is found.


Searches for an element with a given id. Throws if there is more than one element found or nothing is found.


Searches for an input with a particular label attached to it via for attribute. Throws if there is more than one element found or nothing is found.

Verify Methods


Asserts that a given element has a class.


Asserts that a given element has an id.

Waiting for a condition (WaitFor)

Sometimes you may need to wait for something to happen, which you can do with WaitFor(Action action, int timeout = 5000). This will perform an action until it doesn't throw or the timeout is met. A ActionTimedOutException will be thrown if the timeout is reached.

Libraries Used

  • FluentAssertions
  • BUnit
  • RichardSzalay.MockHttp


This library currently only targets net6.0.

Product Versions
.NET net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 261 9/29/2022
1.0.2 250 9/29/2022
1.0.1 249 9/29/2022
1.0.0 256 9/28/2022