Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In bUnit how do I verify an element does not exist

Tags:

bunit

I have the following code:

var li = renderedComponent.Find("li.validation-message");
Assert.Null(li);

The Find() call is throwing an exception instead of returning null. And HasComponent<>() needs a type. It's not clear what type to put in that.

like image 705
David Thielen Avatar asked Oct 28 '25 00:10

David Thielen


1 Answers

There is a FindAll function. That throws no exception if there are no elements, so there is a possibility to check for 0 items

var validationMessages = renderedComponent.FindAll("li.validation-message");
Assert.That(validationMessages, Is.Empty);
like image 135
IceMaur Avatar answered Oct 29 '25 17:10

IceMaur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!