qunit-dom
qunit-dom copied to clipboard
Add `hasHtml` to assert an element has specific HTML
When testing whether dynamic content is rendered correctly as HTML, it would be useful to have a hasHtml
assertion.
This would be the same as hasText
except that instead of testing against textContent
, it would test against innerHTML.trim()
.
The workaround for now is use assert.equal
. For instance:
const html = 'Where you put your <b>emphasis</b> is up to you.',
// cause this HTML to be rendered
assert.equal(document.querySelector('.message').innerHTML.trim(), html);
However, having an hasHtml
built-in would be more idiomatic:
assert.dom('.message').hasHtml(html);