File tree 3 files changed +28
-3
lines changed
3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ function render (TestComponent, {
64
64
return {
65
65
container : wrapper . element . parentNode ,
66
66
baseElement : document . body ,
67
- debug : ( ) => console . log ( prettyDOM ( wrapper . element ) ) ,
67
+ debug : ( el = wrapper . element ) => console . log ( prettyDOM ( el ) ) ,
68
68
unmount : ( ) => wrapper . destroy ( ) ,
69
69
isUnmounted : ( ) => wrapper . vm . _isDestroyed ,
70
70
html : ( ) => wrapper . html ( ) ,
Original file line number Diff line number Diff line change 1
1
<template >
2
- <div >Hello World!</div >
2
+ <div >
3
+ <h1 >Hello World!</h1 >
4
+ <p >Lorem ipsum dolor sit amet</p >
5
+ </div >
3
6
</template >
Original file line number Diff line number Diff line change @@ -10,11 +10,33 @@ afterEach(() => {
10
10
console . log . mockRestore ( )
11
11
} )
12
12
13
- test ( 'debug pretty prints the container' , ( ) => {
13
+ test ( 'debug pretty prints the container if no parameter is provided ' , ( ) => {
14
14
const { debug } = render ( HelloWorld )
15
+
15
16
debug ( )
17
+
18
+ expect ( console . log ) . toHaveBeenCalledTimes ( 1 )
19
+ expect ( console . log ) . toHaveBeenCalledWith (
20
+ expect . stringContaining ( 'Hello World' )
21
+ )
22
+ expect ( console . log ) . toHaveBeenCalledWith (
23
+ expect . stringContaining ( 'Lorem ipsum dolor sit amet' )
24
+ )
25
+ } )
26
+
27
+ test ( 'debug pretty prints the provided parameter' , ( ) => {
28
+ const { getByText, debug } = render ( HelloWorld )
29
+
30
+ // debug accepts a DOM node as a parameter.
31
+ debug ( getByText ( 'Lorem ipsum dolor sit amet' ) )
32
+
16
33
expect ( console . log ) . toHaveBeenCalledTimes ( 1 )
17
34
expect ( console . log ) . toHaveBeenCalledWith (
35
+ expect . stringContaining ( 'Lorem ipsum dolor sit amet' )
36
+ )
37
+
38
+ // Notice the 'not' particle
39
+ expect ( console . log ) . not . toHaveBeenCalledWith (
18
40
expect . stringContaining ( 'Hello World' )
19
41
)
20
42
} )
You can’t perform that action at this time.
0 commit comments