Skip to content

Testing a component rendering to a pre tag with a code tag inside #653

Answered by egil
carlosga asked this question in Q&A
Discussion options

You must be logged in to vote

The two markup snippets are actually not the same, because you are in a pre tag, where whitespace IS significant. MarkupMatches (powered by AngleSharp.Diffing) understands this, and is thus giving you an error, because you have line breaks around the word action in one of the snippets but not the other.

If you do not care about the whitespace in this case, then you can specify that in your expected markup, e.g.:

<pre class="pf-c-code-block__pre" diff:whitespace="RemoveWhitespaceNodes">
  <code class="pf-c-code-block__code">
    action
  </code>
</pre>

Learn more here: https://bunit.dev/docs/verification/semantic-html-comparison.html

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@carlosga
Comment options

Answer selected by carlosga
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants