Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hasHtml to assert an element has specific HTML #2025

Open
fastfedora opened this issue Sep 20, 2023 · 0 comments
Open

Add hasHtml to assert an element has specific HTML #2025

fastfedora opened this issue Sep 20, 2023 · 0 comments

Comments

@fastfedora
Copy link

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant