Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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‎

Lines changed: 17 additions & 0 deletions
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‎

Lines changed: 2 additions & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /