Replies: 7 comments
-
Hi @VGib, I like your idea, but I am not entirely sure it should be part of bUnit's *core) web library, so Ill move this over to the discussion pages for now. A few thoughts though. What you are really testing is not that css matches, but that one or more elements that matches a css selector exists, so perhaps a better name would be Ps. you probably already know this, but |
Beta Was this translation helpful? Give feedback.
-
I think, this would be nice as documentation for beginer. To my view, this is a bad practice to target exactly the Html Output. This explains why some Automatic framework as Selenium are difficult to maintain (one minor change in a template, can change lot of html in the application, and lot of automatics tests may need to be update). I think something like, ShouldHaveHtml( cssSearch) would be nice. |
Beta Was this translation helpful? Give feedback.
-
I agree, thats why I push the semantic HTML comparison in bUnit quite hard, since it will give folks more stable tests: https://bunit.egilhansen.com/docs/verification/verify-markup.html#semantic-comparison-of-markup. As for the naming, |
Beta Was this translation helpful? Give feedback.
-
I agree, does MarkupMatch allows Contains ? |
Beta Was this translation helpful? Give feedback.
-
What do you mean by The Here you can see how you can customizing the semantic comparison: https://bunit.egilhansen.com/docs/verification/semantic-html-comparison.html |
Beta Was this translation helpful? Give feedback.
-
If read correctly the documentation, there is a match only for nodes. But if I want to check the presence of a text. For sample, if I write an error component with a long error message and an error code. I want to check that the right error is displayed, so I won't check the message which may change, I'll check the error code. ... lot of tags div .... <p> ..................... ERROR_CODE .......... <p> ... lot of tags, divs .... I just want to check the ERROR_CODE, and maybe not beeing forced by the html overhead syntax. So We need to compare like this 👍 MarkupMatches("<....>....<p diff-regex>.*?ERROR_CODE.*</p> .... tags ... ") That's what I have understood of MarkupMatches, it compares with AngleSharp, the expected and the razor component output. But, parent tags of p tag can't be ignored. I think this is because AngleSharp attempt to have 2 very close nodes obtain by search. Here, I'd like to search into unknown and changing context. This seems me complicated for complex component. But I may be wrong (one good thing could be to compare after refresh on snapshot, maybe this is what you wanted to do, still it seems me quite complicated). |
Beta Was this translation helpful? Give feedback.
-
MarkupMatches also works with just strings, where it ignores insignificant whitespace. Just do |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
Hello, i want to check just that some text is in the component output. Thiis avoid me to have an assert which will be coupled with the output html code.
For sample, I need to check that some user have been add to a users li list, by checking only with user name.
AngleSharp provides a css selection method:
Describe the solution you'd like
I'd like to have in MarkupAssertMatchExtension an extension method:
Describe alternatives you've considered
I create the extension my self
Additional context
I can implement it if you like (but I need to install visual studio preview and .NET framework 5 preview) and be ready with bunit naming convention.
Beta Was this translation helpful? Give feedback.
All reactions