In one cypress test I just want to check if the server side generated HTML is correct, so I just want to compare it with my expected HTML:
I can do it like this which works fine:
cy.get("table").eq(0).should("have.html",
"<tbody>"
+ "<tr><td><b>Minimale Punktzahl</b>"
+ "</td><td>3</td></tr>"
+ "<tr><td><b>Maximale Punktzahl</b></td><td>10</td></tr>"
+ "</tbody>"
);
But i would rather like to compare it logically and not as a byte sequence.
This should work too, but it doesn’t:
cy.get(".ktable").eq(0).should("have.html",
`<tbody>
<tr>
<td><b>Minimale Punktzahl</b></td>
<td>3</td>
</tr>
<tr>
<td><b>Maximale Punktzahl</b></td>
<td>10</td>
</tr>
</tbody>`);
It doesn’t work because of the whitespace which the server side removes.
I searched for some library which just normalizes the HTML before comparison, but I havn’t found anything.
There must be a JS Lib for comparing two HTML snippets logically.