question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUnit Component.Input(string) does not update @bind-value on Input component

See original GitHub issue

Describe the bug

When using cut.Find(".ant-input").Input("500");, @bind-value does not update.

Steps to reproduce (please include code)

  1. Using BUnit render a component which uses AntDesign.Input
  2. Try to find component ( successful) using css selector .ant-input
  3. Invoke Input method

Further technical details

  • AntDesign Nuget Package version = 0.7.1-nightly-2103091405
  • Include the output of dotnet --info =
.NET SDK (reflecting any global.json):
 Version:   5.0.200
 Commit:    70b3e65d53

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.200\

Host (useful for support):
  Version: 5.0.3
  Commit:  c636bbdc8a

.NET SDKs installed:
  5.0.100-preview.5.20279.10 [C:\Program Files\dotnet\sdk]
  5.0.200 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.5.20279.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.5.20278.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-preview.5.20278.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  • The IDE (VS / VS Code/ VS4Mac) you’re running on, and it’s version = VS 2019 16.9

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
MutatePatcommented, Mar 10, 2021

Final Workaround( end app tests, not AntDesign.Tests):

var cut = Context.RenderComponent<Client.Pages.YOURPAGE>();
var inputCmp = cut.FindComponent<AntDesign.Input<TVALUE>>(); //This finds the input component

inputCmp.SetParametersAndRender(("DebounceMilliseconds", 0)); //Disable Debounce

inputCmp.Find(".ant-input").Input(DATA as STRING); //Enter data
inputCmp.Find(".ant-input").KeyUp(DATA as STRING);

//do test with value
//e.g cut.Find(".ant-btn").Click();

Although it works this issue brings up the following issues:

  1. Debounce working in test env

This means we can’t retrieve the value without adding long delay. This means we need to find component and set parameters on it rather than finding raw css selector

  1. Input and KeyUp required to input data
0reactions
quirynencommented, Jun 24, 2021

Should be part of the documentation since it can be useful to be able to unit test while using AntDesign in production… Anyway thanks for the snippet, it works great !

Read more comments on GitHub >

github_iconTop Results From Across the Web

bUnit not updating bound property
When passing keys from bUnit, the MyValue property, which the input is bound to, doesn't get updated, even though the application works as ......
Read more >
Passing parameters to components
bUnit comes with a number of ways to pass parameters to components under test: In tests written in .razor files, passing parameters is...
Read more >
DebounceDelay property cause unit test to fail in UI for Blazor
I'm integrating bUnit to add unit test to blazor. Now i have a form with some TelerikTextBox and other components with DataAnnotationValidation.
Read more >
[Solved]-Bunit + Radzen, input does not change-blazor
Coding example for the question Bunit + Radzen, input does not change-blazor.
Read more >
probem unittesting with bunit in UI for Blazor
I'm using bUnit to test the Blazor Autocomplete; before the (latest (not sure though)) update the tests passed. The tests do the following:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found