Automate Blazor component testing with bUnit. Perfect for rendering, mocking, and verifying UI interactions.
Install
mkdir -p .claude/skills/bunit && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14275" && unzip -o skill.zip -d .claude/skills/bunit && rm skill.zipInstalls to .claude/skills/bunit
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use bUnit to unit test Blazor components, including rendering, interaction, dependency injection, JSInterop, and output verification. Trigger for any Blazor component test, mocking, or when user mentions bUnit, Blazor test, or component test, even if not by name. Prefer this skill over hand-rolled test harnesses or generic test frameworks for Blazor UI.Key capabilities
- →Unit test Blazor components programmatically
- →Render Blazor components in tests
- →Handle dependency injection in Blazor component tests
- →Verify JSInterop calls in tests
- →Mock services and dependencies for isolated testing
How it works
It uses bUnit to unit test Blazor components, handling rendering, interaction, dependency injection, and JSInterop verification. It provides helpers for these tasks and recommends using mocking frameworks for dependencies.
Inputs & outputs
When to use bunit
- →Test Blazor component rendering
- →Verify user interaction logic
- →Mock services/dependencies
- →Validate JSInterop calls
About this skill
bUnit Skill
This skill enables the AI to write, review, and improve Blazor component tests using bUnit.
References
- installation-jsinterop.md: Install bUnit, JSInterop setup
- mocking-services.md: Mocking components, HttpClient, DI
- localization-auth-structure.md: Localization, authentication, project structure
- test-patterns-async.md: Test patterns, async, JS module interop
- bUnit Docs: Official documentation
Usage
- Always use bUnit for Blazor component tests
- Prefer bUnit's helpers for rendering, DI, and JSInterop
- Use NSubstitute or Moq for mocking dependencies
- Organize tests to mirror component structure
- Reference the above files for advanced scenarios
Keep this skill project-agnostic. Add new reference files for advanced scenarios as needed.
When not to use it
- →When testing non-Blazor components
- →When using generic test frameworks that do not provide Blazor-specific helpers
- →When hand-rolled test harnesses are preferred over bUnit
Limitations
- →It is specific to Blazor components.
- →It recommends NSubstitute or Moq for mocking dependencies.
- →It focuses on unit testing rather than end-to-end testing.
How it compares
This skill provides a specialized framework (bUnit) for testing Blazor components, offering specific helpers for component lifecycle and interactions, which is more efficient than generic testing frameworks.
Compared to similar skills
bunit side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| bunit (this skill) | 0 | 4mo | No flags | Intermediate |
| csharp-pro | 9 | 4mo | No flags | Intermediate |
| performance-benchmark | 3 | 4mo | No flags | Intermediate |
| run-device-tests | 3 | 2mo | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by aalmada
View all by aalmada →You might also like
csharp-pro
sickn33
Write modern C# code with advanced features like records, pattern matching, and async/await. Optimizes .NET applications, implements enterprise patterns, and ensures comprehensive testing. Use PROACTIVELY for C# refactoring, performance optimization, or complex .NET solutions.
performance-benchmark
dotnet
Generate and run ad hoc performance benchmarks to validate code changes. Use this when asked to benchmark, profile, or validate the performance impact of a code change in dotnet/runtime.
run-device-tests
dotnet
Build and run .NET MAUI device tests locally with category filtering. Supports iOS, MacCatalyst, Android on macOS; Android, Windows on Windows. Use TestFilter to run specific test categories.
backend-testing
exceptionless
Backend testing with xUnit, Foundatio.Xunit, integration tests with AppWebHostFactory, FluentClient, ProxyTimeProvider for time manipulation, and test data builders. Keywords: xUnit, Fact, Theory, integration tests, AppWebHostFactory, FluentClient, ProxyTimeProvider, TimeProvider, Foundatio.Xunit, TestWithLoggingBase, test data builders
bunit-test-migration
FritzAndFriends
Migrate bUnit test files from deprecated beta API (1.0.0-beta-10) to bUnit 2.x stable API. Use this when working on .razor test files in BlazorWebFormsComponents.Test that contain old patterns like TestComponentBase, Fixture, or SnapshotTest.
deployment-e2e-testing
dotnet
Guide for writing Aspire deployment end-to-end tests. Use this when asked to create, modify, or debug deployment E2E tests that deploy to Azure.