Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/__tests__/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,20 @@ test('debug pretty prints the provided parameter', () => {
expect.stringContaining('Hello World'),
)
})

test('debug pretty prints multiple nodes with the given parameter', () => {
const {getAllByText, debug} = render(HelloWorld)
const multipleElements = getAllByText(/.+/)

// debug also accepts an array of DOM nodes as a parameter.
debug(multipleElements)

expect(console.log).toHaveBeenCalledTimes(2)
expect(console.log).toHaveBeenCalledWith(
expect.stringContaining('Hello World'),
)

expect(console.log).toHaveBeenCalledWith(
expect.stringContaining('Lorem ipsum dolor sit amet'),
)
})
3 changes: 2 additions & 1 deletion src/vue-testing-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ function render(
return {
container,
baseElement,
debug: (el = baseElement) => logDOM(el),
debug: (el = baseElement) =>
Array.isArray(el) ? el.forEach(e => logDOM(e)) : logDOM(el),
unmount: () => wrapper.destroy(),
isUnmounted: () => wrapper.vm._isDestroyed,
html: () => wrapper.html(),
Expand Down