6
6
teardown ,
7
7
serializeHtml
8
8
} from '../../../test/_util/helpers' ;
9
+ import { vi } from 'vitest' ;
9
10
10
11
/** @jsx createElement */
11
12
@@ -21,13 +22,13 @@ describe('debug with suspense', () => {
21
22
warnings = [ ] ;
22
23
scratch = setupScratch ( ) ;
23
24
rerender = setupRerender ( ) ;
24
- sinon . stub ( console , 'error' ) . callsFake ( e => errors . push ( e ) ) ;
25
- sinon . stub ( console , 'warn' ) . callsFake ( w => warnings . push ( w ) ) ;
25
+ vi . spyOn ( console , 'error' ) . mockImplementation ( e => errors . push ( e ) ) ;
26
+ vi . spyOn ( console , 'warn' ) . mockImplementation ( w => warnings . push ( w ) ) ;
26
27
} ) ;
27
28
28
29
afterEach ( ( ) => {
29
- console . error . restore ( ) ;
30
- console . warn . restore ( ) ;
30
+ console . error . mockRestore ( ) ;
31
+ console . warn . mockRestore ( ) ;
31
32
teardown ( scratch ) ;
32
33
} ) ;
33
34
@@ -74,7 +75,7 @@ describe('debug with suspense', () => {
74
75
render ( suspense , scratch ) ;
75
76
rerender ( ) ; // render fallback
76
77
77
- expect ( console . error ) . to . not . be . called ;
78
+ expect ( console . error ) . not . toHaveBeenCalled ( ) ;
78
79
expect ( serializeHtml ( scratch ) ) . to . equal ( '<div>fallback...</div>' ) ;
79
80
80
81
return loader . then ( ( ) => {
@@ -106,7 +107,7 @@ describe('debug with suspense', () => {
106
107
107
108
return loader . then ( ( ) => {
108
109
rerender ( ) ;
109
- expect ( console . warn ) . to . be . calledTwice ;
110
+ expect ( console . warn ) . toHaveBeenCalledTimes ( 2 ) ;
110
111
expect ( warnings [ 1 ] . includes ( 'MyLazyLoaded' ) ) . to . equal ( true ) ;
111
112
expect ( serializeHtml ( scratch ) ) . to . equal ( '<div>Hi there</div>' ) ;
112
113
} ) ;
@@ -132,7 +133,7 @@ describe('debug with suspense', () => {
132
133
133
134
return loader . then ( ( ) => {
134
135
rerender ( ) ;
135
- expect ( console . warn ) . to . be . calledTwice ;
136
+ expect ( console . warn ) . toHaveBeenCalledTimes ( 2 ) ;
136
137
expect ( warnings [ 1 ] . includes ( 'HelloLazy' ) ) . to . equal ( true ) ;
137
138
expect ( serializeHtml ( scratch ) ) . to . equal ( '<div>Hi there</div>' ) ;
138
139
} ) ;
@@ -160,7 +161,7 @@ describe('debug with suspense', () => {
160
161
}
161
162
162
163
// Called once on initial render, and again when promise rejects
163
- expect ( console . warn ) . to . be . calledTwice ;
164
+ expect ( console . warn ) . toHaveBeenCalledTimes ( 2 ) ;
164
165
} ) ;
165
166
} ) ;
166
167
@@ -181,7 +182,7 @@ describe('debug with suspense', () => {
181
182
error = e ;
182
183
}
183
184
184
- expect ( console . warn ) . to . be . calledOnce ;
185
+ expect ( console . warn ) . toHaveBeenCalledOnce ( ) ;
185
186
expect ( error ) . not . to . be . undefined ;
186
187
expect ( error . message ) . to . eql ( 'Hello' ) ;
187
188
} ) ;
0 commit comments