Skip to content

Commit

Permalink
doc: Better documentation for toContaintHTML (#363)
Browse files Browse the repository at this point in the history
* doc: Better documentation for toContaintHTML
  • Loading branch information
gnapse authored May 15, 2021
1 parent 637529e commit c816955
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ toContainHTML(htmlText: string)
```

Assert whether a string representing a HTML element is contained in another
element:
element. The string should contain valid html, and not any incomplete html.

#### Examples

Expand All @@ -500,7 +500,15 @@ element:
```

```javascript
// These are valid uses
expect(getByTestId('parent')).toContainHTML('<span data-testid="child"></span>')
expect(getByTestId('parent')).toContainHTML('<span data-testid="child" />')
expect(getByTestId('parent')).not.toContainHTML('<br />')

// These won't work
expect(getByTestId('parent')).toContainHTML('data-testid="child"')
expect(getByTestId('parent')).toContainHTML('data-testid')
expect(getByTestId('parent')).toContainHTML('</span>')
```

> Chances are you probably do not need to use this matcher. We encourage testing
Expand Down

0 comments on commit c816955

Please sign in to comment.