Skip to content

Commit

Permalink
feat(debug): allow debugging an array of containers
Browse files Browse the repository at this point in the history
* Allow debug multiple elements

* Split tests using existing templates instead of creating a new one

* Add formater
  • Loading branch information
arnaublanche authored and afontcu committed Oct 21, 2019
1 parent c4eacd2 commit 88cee6f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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

0 comments on commit 88cee6f

Please sign in to comment.