File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -491,7 +491,7 @@ toContainHTML(htmlText: string)
491491```
492492
493493Assert whether a string representing a HTML element is contained in another
494- element:
494+ element. The string should contain valid html, and not any incomplete html.
495495
496496#### Examples
497497
@@ -500,7 +500,15 @@ element:
500500```
501501
502502``` javascript
503+ // These are valid uses
503504expect (getByTestId (' parent' )).toContainHTML (' <span data-testid="child"></span>' )
505+ expect (getByTestId (' parent' )).toContainHTML (' <span data-testid="child" />' )
506+ expect (getByTestId (' parent' )).not .toContainHTML (' <br />' )
507+
508+ // These won't work
509+ expect (getByTestId (' parent' )).toContainHTML (' data-testid="child"' )
510+ expect (getByTestId (' parent' )).toContainHTML (' data-testid' )
511+ expect (getByTestId (' parent' )).toContainHTML (' </span>' )
504512```
505513
506514> Chances are you probably do not need to use this matcher. We encourage testing
You can’t perform that action at this time.
0 commit comments