File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 11// jest.setup.ts
22import '@testing-library/jest-dom' ;
33
4- // Provide a global fetch mock for components using fetch
4+ // Mock global fetch
55global . fetch = jest . fn ( ( ) =>
66 Promise . resolve ( {
77 json : ( ) => Promise . resolve ( [
@@ -25,10 +25,13 @@ global.fetch = jest.fn(() =>
2525 } )
2626) as jest . Mock ;
2727
28- // Suppress React act(...) warnings globally (Jest syntax)
28+ // Suppress React act(...) warnings globally
29+ const originalError = console . error ;
30+
2931beforeAll ( ( ) => {
30- jest . spyOn ( console , 'error' ) . mockImplementation ( ( msg ) => {
32+ jest . spyOn ( console , 'error' ) . mockImplementation ( ( ...args ) => {
33+ const [ msg ] = args ;
3134 if ( typeof msg === 'string' && msg . includes ( 'not wrapped in act' ) ) return ;
32- console . error ( msg ) ;
35+ originalError ( ... args ) ;
3336 } ) ;
3437} ) ;
You can’t perform that action at this time.
0 commit comments