Skip to content

Commit 35522b1

Browse files
author
Kent C. Dodds
authored
feat(debug): accept the same arguments as prettyDOM (#596)
Closes #580
1 parent 107e013 commit 35522b1

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/__tests__/debug.js

+13
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,17 @@ test('debug pretty prints multiple containers', () => {
3636
)
3737
})
3838

39+
test('allows same arguments as prettyDOM', () => {
40+
const HelloWorld = () => <h1>Hello World</h1>
41+
const {debug, container} = render(<HelloWorld />)
42+
debug(container, 6, {highlight: false})
43+
expect(console.log).toHaveBeenCalledTimes(1)
44+
expect(console.log.mock.calls[0]).toMatchInlineSnapshot(`
45+
Array [
46+
"<div>
47+
...",
48+
]
49+
`)
50+
})
51+
3952
/* eslint no-console:0 */

src/pure.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ function render(
6060
return {
6161
container,
6262
baseElement,
63-
debug: (el = baseElement) =>
63+
debug: (el = baseElement, maxLength, options) =>
6464
Array.isArray(el)
6565
? // eslint-disable-next-line no-console
66-
el.forEach(e => console.log(prettyDOM(e)))
66+
el.forEach(e => console.log(prettyDOM(e, maxLength, options)))
6767
: // eslint-disable-next-line no-console,
68-
console.log(prettyDOM(el)),
68+
console.log(prettyDOM(el, maxLength, options)),
6969
unmount: () => ReactDOM.unmountComponentAtNode(container),
7070
rerender: rerenderUi => {
7171
render(wrapUiIfNeeded(rerenderUi), {container, baseElement})

0 commit comments

Comments
 (0)