66 teardown ,
77 serializeHtml
88} from '../../../test/_util/helpers' ;
9+ import { vi } from 'vitest' ;
910
1011/** @jsx createElement */
1112
@@ -21,13 +22,13 @@ describe('debug with suspense', () => {
2122 warnings = [ ] ;
2223 scratch = setupScratch ( ) ;
2324 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 ) ) ;
2627 } ) ;
2728
2829 afterEach ( ( ) => {
29- console . error . restore ( ) ;
30- console . warn . restore ( ) ;
30+ console . error . mockRestore ( ) ;
31+ console . warn . mockRestore ( ) ;
3132 teardown ( scratch ) ;
3233 } ) ;
3334
@@ -74,7 +75,7 @@ describe('debug with suspense', () => {
7475 render ( suspense , scratch ) ;
7576 rerender ( ) ; // render fallback
7677
77- expect ( console . error ) . to . not . be . called ;
78+ expect ( console . error ) . not . toHaveBeenCalled ( ) ;
7879 expect ( serializeHtml ( scratch ) ) . to . equal ( '<div>fallback...</div>' ) ;
7980
8081 return loader . then ( ( ) => {
@@ -106,7 +107,7 @@ describe('debug with suspense', () => {
106107
107108 return loader . then ( ( ) => {
108109 rerender ( ) ;
109- expect ( console . warn ) . to . be . calledTwice ;
110+ expect ( console . warn ) . toHaveBeenCalledTimes ( 2 ) ;
110111 expect ( warnings [ 1 ] . includes ( 'MyLazyLoaded' ) ) . to . equal ( true ) ;
111112 expect ( serializeHtml ( scratch ) ) . to . equal ( '<div>Hi there</div>' ) ;
112113 } ) ;
@@ -132,7 +133,7 @@ describe('debug with suspense', () => {
132133
133134 return loader . then ( ( ) => {
134135 rerender ( ) ;
135- expect ( console . warn ) . to . be . calledTwice ;
136+ expect ( console . warn ) . toHaveBeenCalledTimes ( 2 ) ;
136137 expect ( warnings [ 1 ] . includes ( 'HelloLazy' ) ) . to . equal ( true ) ;
137138 expect ( serializeHtml ( scratch ) ) . to . equal ( '<div>Hi there</div>' ) ;
138139 } ) ;
@@ -160,7 +161,7 @@ describe('debug with suspense', () => {
160161 }
161162
162163 // Called once on initial render, and again when promise rejects
163- expect ( console . warn ) . to . be . calledTwice ;
164+ expect ( console . warn ) . toHaveBeenCalledTimes ( 2 ) ;
164165 } ) ;
165166 } ) ;
166167
@@ -181,7 +182,7 @@ describe('debug with suspense', () => {
181182 error = e ;
182183 }
183184
184- expect ( console . warn ) . to . be . calledOnce ;
185+ expect ( console . warn ) . toHaveBeenCalledOnce ( ) ;
185186 expect ( error ) . not . to . be . undefined ;
186187 expect ( error . message ) . to . eql ( 'Hello' ) ;
187188 } ) ;
0 commit comments