From 0e1d92dd3fcd190d6d7e1505c11d4925bf036eac Mon Sep 17 00:00:00 2001 From: josh-dowdle Date: Tue, 21 Jan 2020 15:18:52 -0700 Subject: [PATCH 1/4] Add documentation for screen.debug. --- docs/dom-testing-library/api-queries.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/dom-testing-library/api-queries.md b/docs/dom-testing-library/api-queries.md index 7b9ff55b5..29366d7e5 100644 --- a/docs/dom-testing-library/api-queries.md +++ b/docs/dom-testing-library/api-queries.md @@ -81,6 +81,26 @@ document.body.innerHTML = exampleHTML const exampleInput = screen.getByLabelText(/example/i) ``` +### `screen.debug` + +For convenience screen also exposes a `debug` method in addition to the queries. +This method is essentially a shortcut for `console.log(prettyDOM())`. It +supports debugging the document, a single element, or an array of elements. + +```jsx +test('exposes debug method', () => { + renderIntoDocument( + `multi-test
multi-test
` + ) + // debug document + screen.debug() + // debug single element + screen.debug(screen.getByText('test')) + // debug multiple elements + screen.debug(screen.getAllByText('multi-test')) +}) +``` + ## Queries > NOTE: These queries are the base queries and require you pass a `container` as From 2c17498017b36b2748898d77e9708a00ab3554a1 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Tue, 28 Jan 2020 15:41:15 -0700 Subject: [PATCH 2/4] Update api-queries.md --- docs/dom-testing-library/api-queries.md | 26 ++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/docs/dom-testing-library/api-queries.md b/docs/dom-testing-library/api-queries.md index 29366d7e5..8a2c67321 100644 --- a/docs/dom-testing-library/api-queries.md +++ b/docs/dom-testing-library/api-queries.md @@ -88,17 +88,21 @@ This method is essentially a shortcut for `console.log(prettyDOM())`. It supports debugging the document, a single element, or an array of elements. ```jsx -test('exposes debug method', () => { - renderIntoDocument( - `multi-test
multi-test
` - ) - // debug document - screen.debug() - // debug single element - screen.debug(screen.getByText('test')) - // debug multiple elements - screen.debug(screen.getAllByText('multi-test')) -}) +import {screen} from '@testing-library/dom' + +document.body.innerHTML = ` + + multi-test +
multi-test
+` + +// debug document +screen.debug() +// debug single element +screen.debug(screen.getByText('test')) +// debug multiple elements +screen.debug(screen.getAllByText('multi-test')) + ``` ## Queries From 02aca194ff1513c2facb299b583977913501dc8a Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Tue, 28 Jan 2020 15:41:34 -0700 Subject: [PATCH 3/4] Update api-queries.md --- docs/dom-testing-library/api-queries.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dom-testing-library/api-queries.md b/docs/dom-testing-library/api-queries.md index 8a2c67321..6b40aeb98 100644 --- a/docs/dom-testing-library/api-queries.md +++ b/docs/dom-testing-library/api-queries.md @@ -87,7 +87,7 @@ For convenience screen also exposes a `debug` method in addition to the queries. This method is essentially a shortcut for `console.log(prettyDOM())`. It supports debugging the document, a single element, or an array of elements. -```jsx +```javascript import {screen} from '@testing-library/dom' document.body.innerHTML = ` From dd386b47496a7b1a4f1b9b6f6e442aef3b3cae78 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Tue, 28 Jan 2020 15:41:51 -0700 Subject: [PATCH 4/4] Update api-queries.md --- docs/dom-testing-library/api-queries.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/dom-testing-library/api-queries.md b/docs/dom-testing-library/api-queries.md index 6b40aeb98..9787eb037 100644 --- a/docs/dom-testing-library/api-queries.md +++ b/docs/dom-testing-library/api-queries.md @@ -102,7 +102,6 @@ screen.debug() screen.debug(screen.getByText('test')) // debug multiple elements screen.debug(screen.getAllByText('multi-test')) - ``` ## Queries