@@ -15,6 +15,21 @@ import { vueVersion } from '~resources/utils'
15
15
import { describeRunIf , itDoNotRunIf } from 'conditional-specs'
16
16
17
17
describeRunIf ( process . env . TEST_ENV !== 'node' , 'shallowMount' , ( ) => {
18
+ let consoleInfoSave = console . info
19
+ let consoleErrorSave = console . error
20
+
21
+ beforeEach ( ( ) => {
22
+ consoleInfoSave = console . info
23
+ consoleErrorSave = console . error
24
+ console . info = jest . fn ( )
25
+ console . error = jest . fn ( )
26
+ } )
27
+
28
+ afterEach ( ( ) => {
29
+ console . info = consoleInfoSave
30
+ console . error = consoleErrorSave
31
+ } )
32
+
18
33
it ( 'renders dynamic class of functional child' , ( ) => {
19
34
const wrapper = shallowMount ( ComponentWithFunctionalChild )
20
35
expect ( wrapper . find ( 'functional-component-stub' ) . classes ( ) ) . toContain (
@@ -58,7 +73,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
58
73
localVue . component ( 'registered-component' , ComponentWithLifecycleHooks )
59
74
mount ( TestComponent , { localVue } )
60
75
61
- expect ( console . info . callCount ) . toEqual ( 4 )
76
+ expect ( console . info ) . toHaveBeenCalledTimes ( 4 )
62
77
} )
63
78
64
79
it ( 'renders children' , ( ) => {
@@ -167,7 +182,7 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
167
182
shallowMount ( Component )
168
183
mount ( Component )
169
184
170
- expect ( console . info . callCount ) . toEqual ( 4 )
185
+ expect ( console . info ) . toHaveBeenCalledTimes ( 4 )
171
186
} )
172
187
173
188
itDoNotRunIf (
@@ -192,7 +207,9 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
192
207
}
193
208
}
194
209
shallowMount ( TestComponent )
195
- expect ( console . error ) . not . calledWith ( sandbox . match ( '[Vue warn]' ) )
210
+ expect ( console . error ) . not . toHaveBeenCalledWith (
211
+ expect . stringMatching ( '[Vue warn]' )
212
+ )
196
213
}
197
214
)
198
215
@@ -297,12 +314,14 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
297
314
}
298
315
const wrapper = shallowMount ( TestComponent )
299
316
expect ( wrapper . html ( ) ) . toContain ( '<test-component-stub>' )
300
- expect ( console . error ) . not . calledWith ( '[Vue warn]' )
317
+ expect ( console . error ) . not . toHaveBeenCalledWith (
318
+ expect . stringMatching ( '[Vue warn]' )
319
+ )
301
320
} )
302
321
303
322
it ( 'does not call stubbed children lifecycle hooks' , ( ) => {
304
323
shallowMount ( ComponentWithNestedChildren )
305
- expect ( console . info . called ) . toEqual ( false )
324
+ expect ( console . info ) . not . toHaveBeenCalled ( )
306
325
} )
307
326
308
327
it ( 'stubs extended components' , ( ) => {
@@ -591,8 +610,8 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'shallowMount', () => {
591
610
}
592
611
shallowMount ( TestComponent )
593
612
mount ( TestComponent )
594
- expect ( console . error ) . not . calledWith (
595
- sandbox . match ( 'Unknown custom element' )
613
+ expect ( console . error ) . not . toHaveBeenCalledWith (
614
+ expect . stringMatching ( 'Unknown custom element' )
596
615
)
597
616
}
598
617
)
0 commit comments