Skip to content

Adding / Mocking JsFunctionalityService & IJSRuntime #1141

Answered by linkdotnet
tenngs asked this question in Q&A
Discussion options

You must be logged in to vote

Ah. Yes - your component should either use the interface version or register the instance.
So in your component do this:

@inject IJsFunctionalityService jsFunctionalityService

Or register inside your bUnit test the instance:

Services.AddScoped<JsFunctionalityService>();

Edit: In your test, you are only registering the interface, but the component is asking for the instance.

Replies: 1 comment 3 replies

Comment options

linkdotnet
Jul 4, 2023
Maintainer Sponsor

You must be logged in to vote
3 replies
@tenngs
Comment options

@linkdotnet
Comment options

linkdotnet Jul 4, 2023
Maintainer Sponsor

Answer selected by tenngs
@tenngs
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants