How to mock JSRuntime #332
Unanswered
minimalisticMe
asked this question in
Q&A
Replies: 1 comment 3 replies
-
What versions of bUnit are you using? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I have a razor component, where I inject a JSRuntime like this:
@inject IJSRuntime jsRuntime
.In the Initializer I call
Now in my Blazor test I mocked the JSRuntime with
JSRuntime = Ctx.Services.AddMockJSRuntime();
but now I don't know how to mock the JS-calls starting withjsRuntime.Window()
.Having a look into
IJSRuntime
, I figured thatWindow()
returns an object of typeValueTask<WindowInterop>
, so I tried to mock withJSRuntime.Setup<ValueTask<WindowInterop>>("Window");
with no success.How do I do this correctly?
Beta Was this translation helpful? Give feedback.
All reactions