Jest-dom: toContainHTML no explanation for error message

Created on 14 Oct 2020  路  3Comments  路  Source: testing-library/jest-dom

After receiving HTML from a function, toContainHTML will throw an error without any explanation. No 'expected', terminal will only show what it received.

Jest test:
expect(getElement('paragraph', 'footer')).toContainHTML('<p class="paragraph second-paragraph" id="id7">this is the second paragraph of footer</p>');

Terminal log:
Received: <p class="paragraph second-paragraph" id="id7">this is the second paragraph of footer</p>

If I use toContainElement, it will throw an error that it receives a string and not an HTML element.

The getElement function will return the HTML element as soon as they find a match with the classes ("class="paragraph second-paragraph")

bug released

All 3 comments

I would like to work on this

@kiranjd thanks, you are very welcome. Go for it!

:tada: This issue has been resolved in version 5.11.8 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

Was this page helpful?
0 / 5 - 0 ratings