dotnet-blazor-testing

Test Blazor components with bUnit, xUnit, and JavaScript interop mocking.

71|10|Updated Feb 11, 2026
One-click install
npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-blazor-testing-wshaddix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-blazor-testing
Source: https://github.com/wshaddix/dotnet-skills/tree/main/skills/dotnet-blazor-testing
Command: npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-blazor-testing-wshaddix

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill streamlines the process of testing Blazor components, ensuring their functionality, rendering, and interactions are correct without needing a full browser environment.

Core Features & Use Cases

  • Component Rendering: Render and assert on the markup of Blazor components.
  • Event Handling: Simulate user interactions like clicks and form submissions.
  • JS Interop Mocking: Mock JavaScript calls made by Blazor components.
  • Cascading Parameters: Test components that rely on cascading values and parameters.
  • Async Lifecycle: Test asynchronous initialization and error states.
  • Use Case: You've built a Blazor component for a counter. Use this Skill to verify that clicking the increment button correctly updates the displayed count.

Quick Start

Use the dotnet-blazor-testing skill to render the Counter component and verify its initial state shows zero.

Frequently Asked Questions about dotnet-blazor-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test Blazor components without launching a full browser environment?

You can test Blazor components without a full browser environment by using the bUnit testing framework to render components, assert markup, and simulate user interactions directly within your test runner. bUnit facilitates component rendering and event handling in memory.

How do I mock JavaScript interop calls when testing Blazor components?

You can mock JavaScript interop calls during Blazor component testing by utilizing the JS Interop Mocking features provided by the bUnit framework. This allows you to simulate JavaScript calls made by Blazor components and verify their execution.

Does bUnit work with xUnit for organizing Blazor component tests?

Yes, bUnit integrates seamlessly with xUnit for organizing and executing Blazor component tests. This integration provides a structured environment for rendering components and verifying asynchronous lifecycle methods and error states.

Can I test Blazor components that rely on cascading values and parameters?

Yes, you can test Blazor components that rely on cascading values and parameters using the bUnit testing framework. bUnit provides specific utilities to inject cascading parameters, allowing you to verify component behavior accurately under various contextual states.

What is the best way to test asynchronous initialization in Blazor components?

The best way to test asynchronous initialization in Blazor components is by using bUnit's state waiting utilities. This framework allows you to test asynchronous lifecycle methods and verify error states without encountering race conditions during component rendering.