File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ function render (TestComponent, {
6464 return {
6565 container : wrapper . element . parentNode ,
6666 baseElement : document . body ,
67- debug : ( ) => console . log ( prettyDOM ( wrapper . element ) ) ,
67+ debug : ( el = wrapper . element ) => console . log ( prettyDOM ( el ) ) ,
6868 unmount : ( ) => wrapper . destroy ( ) ,
6969 isUnmounted : ( ) => wrapper . vm . _isDestroyed ,
7070 html : ( ) => wrapper . html ( ) ,
Original file line number Diff line number Diff line change 11<template >
2- <div >Hello World!</div >
2+ <div >
3+ <h1 >Hello World!</h1 >
4+ <p >Lorem ipsum dolor sit amet</p >
5+ </div >
36</template >
Original file line number Diff line number Diff line change @@ -10,11 +10,33 @@ afterEach(() => {
1010 console . log . mockRestore ( )
1111} )
1212
13- test ( 'debug pretty prints the container' , ( ) => {
13+ test ( 'debug pretty prints the container if no parameter is provided ' , ( ) => {
1414 const { debug } = render ( HelloWorld )
15+
1516 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+
1633 expect ( console . log ) . toHaveBeenCalledTimes ( 1 )
1734 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 (
1840 expect . stringContaining ( 'Hello World' )
1941 )
2042} )
You can’t perform that action at this time.
0 commit comments