Replies: 3 comments 7 replies
-
That's odd, since I know the folks from Blazorise (@Megabit) use bUnit to test Blazorise with themselves 🙂 Perhaps @stsrki has a tutorial on how to get started testing components that use Blazorise components. |
Beta Was this translation helpful? Give feedback.
-
I used the mocks from the sample provided. It worked for a component that displays Alerts, but failed for a model dialog and others with: InvalidOperationException: Cannot provide a value for property 'ModalContext' on type 'Blazorise.Bootstrap5.Modal'. There is no registered service of type 'Blazorise.ModalSharedContext'._ ModalSharedContext is an internal class with no interface. I cannot mock it and I don't see it included in Blazorise.config: You can find the tests that generate this error here marked with [Fact(Skip = "Blazorise mocks not working")] I cloned and attempted to load the Blazorise solution in an effort to dig through how ModalSharedContext is used. However, I ran into a loading issue. I'm using Visual Studio 2022 Professional on Windows 10. The solution load hung on the following. I let it sit for ~20 min. before giving up. How do consumers of Blazorise test with bunit? |
Beta Was this translation helpful? Give feedback.
-
@johniwasz expect it to be exposed in the coming 1.2.2 release Megabit/Blazorise#4662 As for the VS loading issue. Usually, it helps if you delete |
Beta Was this translation helpful? Give feedback.
-
Testing any component that that includes a component from Blazorise fails with:
System.InvalidOperationException : Cannot consume scoped service 'Microsoft.AspNetCore.Components.IComponentActivator' from singleton 'Bunit.Rendering.WebTestRenderer'.
OR:
System.InvalidOperationException : Cannot provide a value for property 'JSModule' on type 'Blazorise.Button'. There is no registered service of type 'Blazorise.Modules.IJSButtonModule'.
Example:
Testing this component:
With this test:
Results in this output:
Or this test:
Results in this output:
Expected behavior:
This line results in successful instantiation of the Counter componet:
Version info:
Additional context:
A repo with a reproduction of this error can be found here:
https://github.com/johniwasz/blazorise-bunit-repro
Beta Was this translation helpful? Give feedback.
All reactions