File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -491,7 +491,7 @@ toContainHTML(htmlText: string)
491
491
```
492
492
493
493
Assert 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.
495
495
496
496
#### Examples
497
497
@@ -500,7 +500,15 @@ element:
500
500
```
501
501
502
502
``` javascript
503
+ // These are valid uses
503
504
expect (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>' )
504
512
```
505
513
506
514
> 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