Skip to content

Commit

Permalink
feat(debug): accept the same arguments as prettyDOM (#596)
Browse files Browse the repository at this point in the history
Closes #580
  • Loading branch information
Kent C. Dodds authored Mar 4, 2020
1 parent 107e013 commit 35522b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/__tests__/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,17 @@ test('debug pretty prints multiple containers', () => {
)
})

test('allows same arguments as prettyDOM', () => {
const HelloWorld = () => <h1>Hello World</h1>
const {debug, container} = render(<HelloWorld />)
debug(container, 6, {highlight: false})
expect(console.log).toHaveBeenCalledTimes(1)
expect(console.log.mock.calls[0]).toMatchInlineSnapshot(`
Array [
"<div>
...",
]
`)
})

/* eslint no-console:0 */
6 changes: 3 additions & 3 deletions src/pure.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ function render(
return {
container,
baseElement,
debug: (el = baseElement) =>
debug: (el = baseElement, maxLength, options) =>
Array.isArray(el)
? // eslint-disable-next-line no-console
el.forEach(e => console.log(prettyDOM(e)))
el.forEach(e => console.log(prettyDOM(e, maxLength, options)))
: // eslint-disable-next-line no-console,
console.log(prettyDOM(el)),
console.log(prettyDOM(el, maxLength, options)),
unmount: () => ReactDOM.unmountComponentAtNode(container),
rerender: rerenderUi => {
render(wrapUiIfNeeded(rerenderUi), {container, baseElement})
Expand Down

0 comments on commit 35522b1

Please sign in to comment.