Replies: 1 comment 1 reply
-
Looking at the actual error message, I see you are trying to set up the runtime to use remote JSInterop and SinglR circuit, most likely because you call But to answer your question, here is an example of setting up logging while testing: https://bunit.dev/docs/misc-test-tips.html#capturing-logs-from-ilogger-in-test-output @stsrki can probably guide you to what is need to configure bUnit's TestContext to render Blazorise components. Im moving this to the discussion forum as this is not a bug. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
I am running into a problem trying to test my Blazor app which uses Blazorise. When I try to render my component
Index
(initially occurred with another page, but also happens with my very simpleIndex
page), it throws an error saying it's unable to resolve a service for the typeILogger
. I cannot find a proper way to inject this, but I also think this is not the proper way to fix it anyway.Initially I ran into the problem of the test not being able to inject
IConfiguration
, but I "fixed" this by usingservices.AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
.I am thinking that something went wrong before that already. In the bUnit documentation, I don't see any configuration being specified, so my guess is I'm already doing something wrong there.
Since the error does not seem to contain Blazorise calls, I assume it's an issue with bUnit, not with Blazorise. If it is, please let me know so I can close this ticket here and move it to the Blazorise repository.
Example:
Testing this component:
App.razor
MainLayout.razor
Index.razor
With this test:
Results in this output:
Expected behavior:
Component
Index
is renderedVersion info:
Additional context:
I am testing my project from a separate test project (
My.Project.Test
testingMy.Project
)Beta Was this translation helpful? Give feedback.
All reactions