Comments (5)
That's a good point. Let's add that to the docs so folks find them when googling.
from bunit.
Pretty sure it's because your test class by default inherits from ComponentBase which you don't want when using it to write tests.
Change it to inherit from Test context instead, e.g. @inherits TestContext
.
@inherits TestContext
@code {
[Fact]
public async Task Should_fire_ValueChanged_event_when_the_value_was_changed()
{
var value = "foo";
var webInput = Render<TestableWebInput<string>>(@<TestableWebInput
TValue="string"
@bind-Value="value">
</TestableWebInput>);
var element = webInput.Find("input");
var wasValueChangedFiredAfterFirstRender = value != "foo";
await element.ChangeAsync(new() { Value = "bar" });
Assert.Multiple(() => Assert.False(wasValueChangedFiredAfterFirstRender),
() => Assert.Equal("bar", webInput.Instance.Value));
}
}
from bunit.
@egil Thank you so much this was it! Keep up the amazing work you do. :)
p.s. I'm not sure whether this is documented but it might be worth adding a note about it.
from bunit.
@iam3yal https://bunit.dev/docs/providing-input/passing-parameters-to-components.html?tabs=razor#configure-two-way-with-component-parameters-bind-directive
from bunit.
@linkdotnet That's great but it's not SEO friendly simply because it doesn't note the exception so a person looking to resolve the problem might not find it but I guess that now that this issue exists it's sufficient. :)
from bunit.
Related Issues (20)
- I got a execption in .NET 8: Method not found: 'System.String Microsoft.AspNetCore.Components.CascadingParameterAttributeBase.get_Name()'. HOT 1
- `Render(RenderFragment)` doesn't re-render and has other limitations HOT 9
- `IRenderedComponent.InvokeAsync` should support return values HOT 8
- Enable test doubles for (3rd party) components generation HOT 20
- Problems running docs project locally HOT 6
- Docs: search exposes pages that are not in the TOC
- bunit.web has dependency on alpha version of AngleSharp.Css HOT 2
- No way to set value for property with `[SupplyParameterFromQuery]` but not `[Parameter]` HOT 6
- Support for keyed services HOT 5
- Cannot trigger RowSelected eventcallback on SFgrid HOT 3
- `WrapperElementsGenerator` cachable
- IJSUnmarshalledRuntime removed in .NET 9 HOT 2
- FakeNavigationManager registration changed from Singleton to Scoped HOT 7
- bUnit does not set parameters as a result of two-way binding or chained binding when values are updated. HOT 6
- `@formname` attribute always causes an error: System.InvalidOperationException : Invalid element frame type 'NamedEvent' HOT 2
- upgrading bUnit to 1.27.17 results in bunit.web.testcomponents load errors HOT 2
- WASM MSAL Configuration Not Correctly Supported HOT 1
- Async Task in Multiple Tests HOT 8
- Clicking an Anchor Tag does not update NavigationManager HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bunit.