Skip to content

Commit 81ce42d

Browse files
jkdowdlekentcdodds
andauthored
Add documentation for screen.debug. (#362)
* Add documentation for screen.debug. * Update api-queries.md * Update api-queries.md * Update api-queries.md Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
1 parent 0cccb30 commit 81ce42d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/dom-testing-library/api-queries.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,29 @@ document.body.innerHTML = exampleHTML
8181
const exampleInput = screen.getByLabelText(/example/i)
8282
```
8383

84+
### `screen.debug`
85+
86+
For convenience screen also exposes a `debug` method in addition to the queries.
87+
This method is essentially a shortcut for `console.log(prettyDOM())`. It
88+
supports debugging the document, a single element, or an array of elements.
89+
90+
```javascript
91+
import {screen} from '@testing-library/dom'
92+
93+
document.body.innerHTML = `
94+
<button>test</button>
95+
<span>multi-test</span>
96+
<div>multi-test</div>
97+
`
98+
99+
// debug document
100+
screen.debug()
101+
// debug single element
102+
screen.debug(screen.getByText('test'))
103+
// debug multiple elements
104+
screen.debug(screen.getAllByText('multi-test'))
105+
```
106+
84107
## Queries
85108

86109
> NOTE: These queries are the base queries and require you pass a `container` as

0 commit comments

Comments
 (0)