Testing a Syncfusion component using bUnit #242
alecrisan
started this conversation in
Show and tell
Replies: 1 comment 10 replies
-
Does this still work?? Bunit.JSRuntimeUnhandledInvocationException
The invocation of 'import' with the argument [./_content/Syncfusion.Blazor/scripts/syncfusion-blazor.min.js] was not expected. var context = new TestContext();
context.Services.AddSyncfusionBlazor();
context.Services.AddScoped(_ => toaster ?? A.Dummy<IToastService>())
.AddScoped(_ => gameRepo ?? A.Dummy<IGameRepository>())
.AddScoped(_ => defaultRepo ?? A.Dummy<IDefaultArgsRepository>());
// That one throws
var page = context.RenderComponent<DefaultArgs>(); Page: @page "/DefaultArgs"
@using GameBuddy.Models.Contract
@using GameBuddy.Shared
@using System.Collections.ObjectModel
@using IDefaultArgsRepository = GameBuddy.Shared.Repositories.Contracts.IDefaultArgsRepository
@using IGameRepository = GameBuddy.Shared.Repositories.Contracts.IGameRepository
@inject IDefaultArgsRepository Repo;
@inject IGameRepository GameRepo;
@inject IToastService Toaster;
<h3>DefaultArgs</h3>
<SfCheckBox Label="Apply to all existing Games" @bind-Checked="@updateEntities"/> |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a quick guide for testing syncfusion components using bUnit.
Here is a simple example of a test for the SfDialog component that checks the title of the dialog:
Basically the most important thing you need to do is add syncfusion to the services collection:
Services.AddSyncfusionBlazor();
And then you're good to go!
Razor component:
Beta Was this translation helpful? Give feedback.
All reactions