finds.dev← search

// the find

bUnit-dev/bUnit

★ 1,304 · C# · MIT · updated Sep 2026

bUnit is a testing library for Blazor components that make tests look, feel, and runs like regular unit tests. bUnit makes it easy to render and control a component under test’s life-cycle, pass parameter and inject services into it, trigger event handlers, and verify the rendered markup from the component using a built-in semantic HTML comparer.

bUnit is a unit-testing library for Blazor components that renders them in-memory (no browser) so you can assert on markup, trigger events, and inject services the way you would with any xUnit/NUnit/MSTest test. It's for anyone writing Blazor components who wants fast, isolated component tests instead of full Playwright/Selenium runs for every behavior.

The semantic HTML comparer is the standout feature — it diffs DOM structure instead of raw strings, so tests don't break on attribute ordering or whitespace, which is where naive snapshot testing usually falls apart. It ships test doubles for the actually painful parts of Blazor testing: IJSRuntime, auth state, NavigationManager, PersistentComponentState — things you'd otherwise hand-roll per project. It's framework-agnostic across xUnit, NUnit, MSTest and TUnit rather than forcing a runner on you, and the source generators (bunit.generators) cut down component-stub boilerplate. Backed by .NET Foundation with real release cadence and an explicit migration guide between major versions.

It's a simulated renderer, not a browser — no actual JS execution, no CSS layout, no real DOM quirks, so interop timing bugs or CSS-driven behavior won't show up here and you still need Playwright or similar for that layer. The 1.x/2.x split means anything below .NET 8 is stuck on the older, now-secondary branch, which is a trap if you're not watching the compatibility matrix. Render-mode edge cases (prerendering, streaming SSR interaction with interactive components) are thin in the docs relative to how much Blazor's hosting models have fragmented. The semantic comparer's AngleSharp-based normalization can also produce diffs that are technically correct but non-obvious to read when markup gets deeply nested.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →