Dabbler.Testing.Blazor 1.0.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Dabbler.Testing.Blazor --version 1.0.0
                    
NuGet\Install-Package Dabbler.Testing.Blazor -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="Dabbler.Testing.Blazor" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dabbler.Testing.Blazor" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Dabbler.Testing.Blazor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dabbler.Testing.Blazor --version 1.0.0
                    
#r "nuget: Dabbler.Testing.Blazor, 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.
#:package Dabbler.Testing.Blazor@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dabbler.Testing.Blazor&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Dabbler.Testing.Blazor&version=1.0.0
                    
Install as a Cake Tool

Dabbler.Testing.Blazor

Part of the Dabbler Platform. See docs/platform-overview.md for the platform-level view of how this library fits in.

Testing utilities for Blazor Server apps. Emphasis on deterministic synchronization for Playwright E2E tests via an action-watermark mechanism that exposes when components have settled after async work.

Audience

Teams writing Playwright E2E tests against Blazor Server apps who are frustrated by the click-then-arbitrary-wait pattern and want a test-time signal that says "the click's handler finished AND the re-render committed." This is the platform's answer to one of the hardest E2E synchronization problems on Blazor Server.

Prerequisites and stack constraints

  • Blazor Server
  • .NET 10 (current LTS)
  • Microsoft.AspNetCore.Components.Web
  • (Optional) Playwright for the E2E side; this library does not depend on Playwright but is designed to be observed by it

Install

Adoption note: The recommended adoption model for internal projects is integrated source under src/Libs/Dabbler.Testing.Blazor/. NuGet packages are available; to install the package: dotnet add package Dabbler.Testing.Blazor --prerelease

Minimal registration

// Program.cs
using Dabbler.Testing.Blazor.Hosting;

builder.Services.AddTrackedActions(builder.Configuration);

Enable the tracker in appsettings.Development.json:

{
  "Testing": {
    "ActionTracking": {
      "Enabled": true
    }
  }
}

It's false by default — so production deployments that happen to ship this assembly carry zero runtime cost when not enabled.

Smallest working example

1. Wire the JS shim into your app

In App.razor:

@inject IOptions<TrackedActionsOptions> Options

@code {
    private bool Enabled => Options.Value.Enabled;
}

@if (Enabled)
{
    <script src="_content/Dabbler.Testing.Blazor/dabbler-tracked-actions.js"></script>
}

2. Add a readiness probe

In MainLayout.razor:

@using Dabbler.Testing.Blazor.Components

<TestReadinessProbe />

3. Opt a component into watermarked actions

public class OrderActions : TrackedComponentBase
{
    private async Task SaveOrderAsync()
    {
        await TrackAction("save-order", async () =>
        {
            await _service.SaveAsync(_model);
        });
    }
}

4. Use the watermark from Playwright

// After clicking a button that triggers a handler:
await page.GetByTestId("save-order").ClickAsync();
await Assertions.Expect(page.Locator("html"))
    .ToHaveAttributeAsync("data-actions-in-flight", "[]");

Or wait for initial readiness:

await Assertions.Expect(page.Locator("html"))
    .ToHaveAttributeAsync("data-blazor-ready", "true");

Configuration

Setting Type Default Notes
Testing:ActionTracking:Enabled bool false Set to true in Development; false in Production (safe no-op).

Features

  • Action watermark tracking — DOM attributes (data-actions-in-flight, data-last-action, data-render-version) expose when Blazor components have settled after user actions.
  • Test readiness probe — Signals when the initial page load is complete via data-blazor-ready.
  • TrackedComponentBase — Opt-in base class for components that perform async work in event handlers.
  • JS interop shim — Low-overhead JavaScript module that maintains watermark attributes.
  • Dabbler.Components — typical consumer of the watermark (CRUD pages that drive grid refreshes from async handlers).
  • Dabbler.Security.Blazor — admin pages that opt into watermarked actions for E2E coverage of permission-edit flows.
  • Dabbler.Platform.Stubs — pairs with the watermark for bUnit tests that simulate async handlers against stub providers.

Warnings and caveats

  • Watermark is opt-in, not automatic. Components inherit TrackedComponentBase and wrap async handlers in TrackAction(...) to be observed; uninstrumented handlers are invisible to Playwright's watermark wait.
  • Animation waits (CSS transitions) are not render-correlated and still require Task.Delay() with documentation.
  • External login pages (e.g., DevIdp) don't set data-blazor-ready and require conditional handling in Playwright fixtures.
  • TrackAction's JS-interop calls go through TryInvokeJsAsync and silently no-op if IJSRuntime is not yet dispatchable (prerender boundary, intermediate render passes). Missing the watermark in those frames degrades to "no signal" rather than failing the page render. Without this guard, an early-fire of a TrackAction-wrapped event handler turns into an HTTP 500.
  • License: MIT (see LICENSE).

If this library stops being maintained

This package is MIT-licensed, and its source is in src/Libs/Dabbler.Testing.Blazor. If it stops being maintained, copy that source into your application, replace the package reference with a project reference to your copy, and own it from there. Keep the MIT license notice with the copied code.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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
2.0.2 94 11/13/2026
2.0.1 92 11/13/2026
2.0.0 87 11/13/2026
1.0.0 95 11/9/2026
0.1.0-preview.1 111 5/30/2026