File tree Expand file tree Collapse file tree 2 files changed +44
-46
lines changed Expand file tree Collapse file tree 2 files changed +44
-46
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,50 @@ console.log(prettyDOM(div))
103
103
This function is what also powers
104
104
[the automatic debugging output described above](#debugging).
105
105
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
+
106
150
## ` logRoles `
107
151
108
152
This helper function can be used to print out a list of all the implicit ARIA
Original file line number Diff line number Diff line change @@ -347,52 +347,6 @@ screen.getByText('text', {
347
347
})
348
348
```
349
349
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
-
396
350
## Manual Queries
397
351
398
352
On top of the queries provided by the testing library, you can use the regular
You can’t perform that action at this time.
0 commit comments