var jsRuntimeMock = Mock.Create<IJSRuntime>(); Could not load file or assembly 'xunit.assert, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.' #1175
-
I am creating a blazor unit test which involves a TelerikMaskedTextbox. I followed their guidance by creating the class located at If I run the test, it passes just fine. If I debug the test, it crashes with the following error:
It crashes on the following line in the constructor // mock the JS Interop service, you cannot use the one coming from the context
var jsRuntimeMock = Mock.Create<IJSRuntime>(); I am also occasionally seeing the following in the test output:
Per the error message, I tried: adding public TelerikTestContextWithActualRoot()
{
JSInterop.Mode = JSRuntimeMode.Loose;
JSInterop.SetupVoid("mudPopover.connect", _ => true);
JSInterop.SetupVoid("mudElementRef.restoreFocus", _ => true);
// mock the JS Interop service, you cannot use the one coming from the context
var jsRuntimeMock = Mock.Create<IJSRuntime>();// This is Telerik.JustMock.Mock
// you can also register a real one for actual localization to test that too
var localizerMock = Mock.Create<ITelerikStringLocalizer>();
} But I still get the same error. I also tried installing the XUnit nuget package which did not help. As I stated earlier, the passes if I just run it from the VS 2022 Test Explorer. I only see this error if I run the test in debug mode, which seems strange. Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
If you go about it as Telerik suggests and replace the IJSRuntime with a mock, the built-in handler for JSInterop in bUnit doesn't work anymore. I will ping the Telerik folks and see what can be done to make bUnits JSInterop work with their components. I am not sure about the "Could not load file or assembly 'xunit.assert..." error you are seeing though, it may be something that @EdCharbeneau or one of the other folks from @telerik knows what's up with. ps. edited your post's markdown a bit to make it more readable. |
Beta Was this translation helpful? Give feedback.
I just saw your suggestion and implement it.
@dwarwick you can see the latest version in the PR: telerik/blazor-ui#259.
Thanks, @dwarwick and @egil for bringing this to us. 🙏