How to mock Blazor Hotkeys library in blazor component? #828
JGSilverman
started this conversation in
General
Replies: 1 comment
-
Hey @JGSilverman just add public void MyTest()
{
Services.AddHotKeys();
var cut = RenderComponent<MyComponentWithHotKeys>();
// ...
} Something similar you did anyway in your production code. The README describes this very well. As your production service-container is a different on than your test container, you have to register it in both places. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a fairly standard blazor component, but we are using the Blazor Hotkeys library found here inside the component. It is used like this:
When creating a bUnit test for this component, without the hotkeys it blows up with
SystemInvalidOperationException: .... There is no registered service of type 'Toolbelt.Blazor.HotKeys.HotKeys'.
How do I wire this up so I can test my component?
Beta Was this translation helpful? Give feedback.
All reactions