Skip to content

Commit ccd51e2

Browse files
tomalaforgeThomasL
andauthored
update debug doc (#1279)
Co-authored-by: ThomasL <[email protected]>
1 parent 8299daf commit ccd51e2

File tree

2 files changed

+44
-46
lines changed

2 files changed

+44
-46
lines changed

docs/dom-testing-library/api-debugging.mdx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,50 @@ console.log(prettyDOM(div))
103103
This function is what also powers
104104
[the automatic debugging output described above](#debugging).
105105
106+
## `screen.debug()`
107+
108+
For convenience `screen` also exposes a `debug` method.
109+
This method is essentially a shortcut for `console.log(prettyDOM())`. It
110+
supports debugging the document, a single element, or an array of elements.
111+
112+
```javascript
113+
import {screen} from '@testing-library/dom'
114+
115+
document.body.innerHTML = `
116+
<button>test</button>
117+
<span>multi-test</span>
118+
<div>multi-test</div>
119+
`
120+
121+
// debug document
122+
screen.debug()
123+
// debug single element
124+
screen.debug(screen.getByText('test'))
125+
// debug multiple elements
126+
screen.debug(screen.getAllByText('multi-test'))
127+
```
128+
129+
## `screen.logTestingPlaygroundURL()`
130+
131+
For debugging using [testing-playground](https://testing-playground.com), screen
132+
exposes this convenient method which logs and returns a URL that can be opened in
133+
a browser.
134+
135+
```javascript
136+
import {screen} from '@testing-library/dom'
137+
138+
document.body.innerHTML = `
139+
<button>test</button>
140+
<span>multi-test</span>
141+
<div>multi-test</div>
142+
`
143+
144+
// log entire document to testing-playground
145+
screen.logTestingPlaygroundURL()
146+
// log a single element
147+
screen.logTestingPlaygroundURL(screen.getByText('test'))
148+
```
149+
106150
## `logRoles`
107151
108152
This helper function can be used to print out a list of all the implicit ARIA

docs/queries/about.mdx

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -347,52 +347,6 @@ screen.getByText('text', {
347347
})
348348
```
349349

350-
## Debugging
351-
352-
### `screen.debug()`
353-
354-
For convenience screen also exposes a `debug` method in addition to the queries.
355-
This method is essentially a shortcut for `console.log(prettyDOM())`. It
356-
supports debugging the document, a single element, or an array of elements.
357-
358-
```javascript
359-
import {screen} from '@testing-library/dom'
360-
361-
document.body.innerHTML = `
362-
<button>test</button>
363-
<span>multi-test</span>
364-
<div>multi-test</div>
365-
`
366-
367-
// debug document
368-
screen.debug()
369-
// debug single element
370-
screen.debug(screen.getByText('test'))
371-
// debug multiple elements
372-
screen.debug(screen.getAllByText('multi-test'))
373-
```
374-
375-
### `screen.logTestingPlaygroundURL()`
376-
377-
For debugging using [testing-playground](https://testing-playground.com), screen
378-
exposes this convenient method which logs and returns a URL that can be opened in
379-
a browser.
380-
381-
```javascript
382-
import {screen} from '@testing-library/dom'
383-
384-
document.body.innerHTML = `
385-
<button>test</button>
386-
<span>multi-test</span>
387-
<div>multi-test</div>
388-
`
389-
390-
// log entire document to testing-playground
391-
screen.logTestingPlaygroundURL()
392-
// log a single element
393-
screen.logTestingPlaygroundURL(screen.getByText('test'))
394-
```
395-
396350
## Manual Queries
397351

398352
On top of the queries provided by the testing library, you can use the regular

0 commit comments

Comments
 (0)