Rask.Testing 0.19.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Rask.Testing --version 0.19.0
                    
NuGet\Install-Package Rask.Testing -Version 0.19.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="Rask.Testing" Version="0.19.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Rask.Testing" Version="0.19.0" />
                    
Directory.Packages.props
<PackageReference Include="Rask.Testing" />
                    
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 Rask.Testing --version 0.19.0
                    
#r "nuget: Rask.Testing, 0.19.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 Rask.Testing@0.19.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=Rask.Testing&version=0.19.0
                    
Install as a Cake Addin
#tool nuget:?package=Rask.Testing&version=0.19.0
                    
Install as a Cake Tool

Rask.Testing

Unit-test Rask components — render a component to HTML, invoke its event handlers, and assert on the re-rendered markup. No browser, no server, no WebSocket.

using Rask.Testing;

public sealed class Counter : Component
{
    private int _count;
    protected override Component? Render() =>
        Button(Type: "button", OnClick: () => _count++)[$"Count: {_count}"];
}

[Fact]
public async Task Clicking_increments()
{
    var page = RaskTest.Render(new Counter());
    Assert.Contains("Count: 0", page.Html);

    await page.ClickAsync();               // dispatch the click handler + re-render
    Assert.Contains("Count: 1", page.Html);
}

API

  • RaskTest.Render(component, services?) → a RenderedComponent. Renders the component with its event handlers wired; pass an IServiceProvider when the component constructor-injects services.
  • RaskTest.Render(factory, services?) — same, but the factory runs on every render, so the tree is rebuilt from your current state each time. Use it whenever a re-render should see changed props: RaskTest.Render(() => Form(model)[Input(() => model.Name)]). The component overload renders one fixed instance, so a tree you build at the call site keeps the values it was built with.
  • RenderedComponent.Html — the current markup, reflecting the latest state.
  • .ClickAsync(json?) / .InvokeAsync(handlerId, json?) — dispatch a handler (optionally with a JSON event payload like "{\"value\":\"hi\"}" for an input) and re-render; returns the new Html.
  • .HandlerId(domEvent) — the handler id wired to "click"/"input"/"change"/"submit"/…
  • .Attr(name) — the first name="…" attribute value in the current Html.
  • .HandlerIds(domEvent) / .Attrs(name) — every match, in document order. Index these to target one of several same-event elements: await page.InvokeAsync(page.HandlerIds("click")[1]).
  • Markup.Attr(html, name) / Markup.Attrs(html, name) — the same lookups over any HTML string.
  • .TryInvokeAsync(handlerId, json?) — dispatch only if the id is still live; returns false rather than throwing, so you can assert a handler is gone.
  • .Instance — the component object you passed in, for asserting its state directly.
  • .Render() — re-render after mutating external state the component reads.
  • TestJSRuntime — an IJSRuntime that records calls and returns canned values, for components that inject IJSRuntime. Register it in the provider, then assert with .ArgsFor(id) / .Calls / .CallCount(id); configure with .SetResponse(id, value) / .SetException(id, ex).
  • RaskTest.EditContextProbe(capture) — placed inside a Form's children, hands you the form's EditContext so you can assert validation state (GetValidationMessages, IsModified, IsValidating) that never appears in the markup.

Install

Reference from your test project. Rask.Core comes transitively from the app under test (via its Rask.Server / Rask.Wasm reference), so you don't reference it directly.

dotnet add <YourApp>.Tests package Rask.Testing

See the testing guide for forms, validation, and DI examples.

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
0.19.1-alpha.0.62 0 8/5/2026
0.19.1-alpha.0.57 0 8/5/2026
0.19.1-alpha.0.51 0 8/5/2026
0.19.1-alpha.0.43 15 8/5/2026
0.19.1-alpha.0.42 21 8/5/2026
0.19.1-alpha.0.40 20 8/5/2026
0.19.1-alpha.0.38 34 8/5/2026
0.19.1-alpha.0.32 24 8/5/2026
0.19.1-alpha.0.31 30 8/4/2026
0.19.1-alpha.0.30 23 8/4/2026
0.19.1-alpha.0.28 27 8/4/2026
0.19.1-alpha.0.25 28 8/4/2026
0.19.1-alpha.0.24 31 8/4/2026
0.19.1-alpha.0.23 30 8/4/2026
0.19.1-alpha.0.14 44 8/3/2026
0.19.1-alpha.0.13 37 8/3/2026
0.19.1-alpha.0.12 39 8/3/2026
0.19.1-alpha.0.11 44 8/3/2026
0.19.1-alpha.0.6 32 8/3/2026
0.19.0 98 7/20/2026
Loading failed