Testing a component that calls a real API or touches a real database is slow and flaky. We use Mocks to stay in control.
In bUnit, you can provide a mock implementation of any injected service. ctx.Services.AddSingleton<IApiClient>(mockClient);. Your component thinks it's talking to the real API, but it's actually receiving data that you control in your test setup.
Mocking Javascript is traditionally hard. bUnit makes it easy with its built-in JSInterop mock engine. You can verify that your C# code called console.log or that it successfully received a value from a JS prompt, all without running a single line of real Javascript.
Q: "Should I mock the HttpClient?"
Architect Answer: "Avoid it if possible. Instead of mocking the low-level HttpClient, mock your high-level **API Client interface** (e.g., IOrderService). This makes your tests much less brittle and more focused on the business behavior of the UI rather than the technical details of JSON serialization."