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 920dff2

Browse files
authored
feat(debug): Add maxLength and options to debug (#164)
1 parent d356049 commit 920dff2

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

‎src/__tests__/debug.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,19 @@ test('debug pretty prints multiple nodes with the given parameter', () => {
5757
expect.stringContaining('Lorem ipsum dolor sit amet'),
5858
)
5959
})
60+
61+
test('allows same arguments as prettyDOM', () => {
62+
const {debug, container} = render(HelloWorld)
63+
64+
// debug accepts a maxLength and an options parameters:
65+
// https://testing-library.com/docs/dom-testing-library/api-helpers#prettydom
66+
debug(container, 6, {highlight: false})
67+
68+
expect(console.log).toHaveBeenCalledTimes(1)
69+
expect(console.log.mock.calls[0]).toMatchInlineSnapshot(`
70+
Array [
71+
<div>
72+
...,
73+
]
74+
`)
75+
})

‎src/vue-testing-library.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {createLocalVue, mount} from '@vue/test-utils'
33

44
import {
55
getQueriesForElement,
6-
logDOM,
6+
prettyDOM,
77
waitFor,
88
fireEvent as dtlFireEvent,
99
} from '@testing-library/dom'
@@ -72,8 +72,10 @@ function render(
7272
return {
7373
container,
7474
baseElement,
75-
debug: (el = baseElement) =>
76-
Array.isArray(el) ? el.forEach(e => logDOM(e)) : logDOM(el),
75+
debug: (el = baseElement, maxLength, options) =>
76+
Array.isArray(el)
77+
? el.forEach(e => console.log(prettyDOM(e, maxLength, options)))
78+
: console.log(prettyDOM(el, maxLength, options)),
7779
unmount: () => wrapper.destroy(),
7880
isUnmounted: () => wrapper.vm._isDestroyed,
7981
html: () => wrapper.html(),

0 commit comments

Comments
(0)

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