Skip to content

Commit 88cee6f

Browse files
arnaublancheafontcu
authored andcommitted
feat(debug): allow debugging an array of containers
* Allow debug multiple elements * Split tests using existing templates instead of creating a new one * Add formater
1 parent c4eacd2 commit 88cee6f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/__tests__/debug.js

+17
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,20 @@ test('debug pretty prints the provided parameter', () => {
3939
expect.stringContaining('Hello World'),
4040
)
4141
})
42+
43+
test('debug pretty prints multiple nodes with the given parameter', () => {
44+
const {getAllByText, debug} = render(HelloWorld)
45+
const multipleElements = getAllByText(/.+/)
46+
47+
// debug also accepts an array of DOM nodes as a parameter.
48+
debug(multipleElements)
49+
50+
expect(console.log).toHaveBeenCalledTimes(2)
51+
expect(console.log).toHaveBeenCalledWith(
52+
expect.stringContaining('Hello World'),
53+
)
54+
55+
expect(console.log).toHaveBeenCalledWith(
56+
expect.stringContaining('Lorem ipsum dolor sit amet'),
57+
)
58+
})

src/vue-testing-library.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ function render(
6868
return {
6969
container,
7070
baseElement,
71-
debug: (el = baseElement) => logDOM(el),
71+
debug: (el = baseElement) =>
72+
Array.isArray(el) ? el.forEach(e => logDOM(e)) : logDOM(el),
7273
unmount: () => wrapper.destroy(),
7374
isUnmounted: () => wrapper.vm._isDestroyed,
7475
html: () => wrapper.html(),

0 commit comments

Comments
 (0)