Can external components be used in bUnit ie. AntBlazor? #826
gerickehoeksema
started this conversation in
General
Replies: 1 comment 1 reply
-
Hey @gerickehoeksema I am not an expert or user of AntBlazor myself, so this is just what I found out while browsing through their code. Registering the service does not seem enough. You see the error because of this line taken from Alert.razor.cs: protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (firstRender)
{
HtmlElement element = await JsInvokeAsync<HtmlElement>(JSInteropConstants.GetDomInfo, Ref);
_height = element.ClientHeight;
}
} The JsInvoke will return a |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm fairly new to Blazor, AntBlazor, and bUnit. I wanted to perform a cut but came across an issue where an AntBlazor component is throwing an exception when it needs to render although the service gets registered in the TextContext.
TestContext.Services.AddAntDesign();
This is the exception being thrown Object reference not set to an instance of an object. at AntDesign.Alert.OnAfterRenderAsync(Boolean firstRender)
This is the alert component
<Alert Type="@AlertType.Error" Message="Error text" Closable class="mb-3" />
When the external component doesn't need to render then the test passes.
My question would be, is there any additional setup that needs to happen to be able to successfully test AntBlazor components?
Beta Was this translation helpful? Give feedback.
All reactions