-
Notifications
You must be signed in to change notification settings - Fork 353
Description
I noticed that TelerikTestContext and TelerikTestContextWithActualRoot are replacing bUnits built-in IJSRuntime with a mock. While it does work, there are a bunch of edge cases and 1st party components that bUnit's version is configured to handle out of the box (e.g. the Virtualize component), so a better approach would be to set up everything that is needed to render Telerik components directly.
There are a bunch of ways to achieve this, so I am curious what // mock the JS Interop service, you cannot use the one coming from the context refers to and will gladly help resolve any issues that are (if possible). If possible, outline the JSInterop requirements and I can help set things up.
blazor-ui/testing/bUnit-justmock/Telerik.Blazor.BUnit.JustMock/Common/TelerikTestContext.cs
Lines 21 to 35 in 8892d4f
| public TelerikTestContext() | |
| { | |
| // mock the JS Interop service, you cannot use the one coming from the context | |
| var jsRuntimeMock = Mock.Create<IJSRuntime>(); | |
| // you can also register a real one for actual localization to test that too | |
| var localizerMock = Mock.Create<ITelerikStringLocalizer>(); | |
| // make sure JS Interop is available first | |
| Services.AddSingleton(jsRuntimeMock); | |
| // add the Telerik Blazor services like in a regular app | |
| Services.AddTelerikBlazor(); | |
| Services.AddSingleton(localizerMock); | |
| } |
Related: bUnit-dev/bUnit#1175