mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	chore: silence remaining front end test warnings (#8465)
This silences front end test warnings, errors, and logs that we don't care about. The reason we don't care is that: - we won't fix - it's test-specific, doesn't appear to happen in real life And it clogs the test logs.
This commit is contained in:
		
							parent
							
								
									d5ddbdd75f
								
							
						
					
					
						commit
						bb22210e46
					
				| @ -15,19 +15,40 @@ if (!window.ResizeObserver) { | ||||
| 
 | ||||
| process.env.TZ = 'UTC'; | ||||
| 
 | ||||
| const errorsToIgnore = [ | ||||
|     'Warning: An update to %s inside a test was not wrapped in act', | ||||
|     "Failed to create chart: can't acquire context from the given item", | ||||
| ]; | ||||
| 
 | ||||
| const warningsToIgnore = [ | ||||
|     '[MSW] Found a redundant usage of query parameters in the request handler URL for', | ||||
|     'MUI: You have provided an out-of-range value', | ||||
| ]; | ||||
| 
 | ||||
| const logsToIgnore = ['An exception was caught and handled.']; | ||||
| 
 | ||||
| // ignore known React warnings
 | ||||
| const consoleError = console.error; | ||||
| const consoleWarn = console.warn; | ||||
| const consoleLog = console.log; | ||||
| beforeAll(() => { | ||||
|     const shouldIgnore = (messagesToIgnore: string[], args: any[]) => | ||||
|         typeof args[0] === 'string' && | ||||
|         messagesToIgnore.some((msg) => args[0].includes(msg)); | ||||
| 
 | ||||
|     vi.spyOn(console, 'error').mockImplementation((...args) => { | ||||
|         if ( | ||||
|             !( | ||||
|                 typeof args[0] === 'string' && | ||||
|                 args[0].includes( | ||||
|                     'Warning: An update to %s inside a test was not wrapped in act', | ||||
|                 ) | ||||
|             ) | ||||
|         ) { | ||||
|         if (!shouldIgnore(errorsToIgnore, args)) { | ||||
|             consoleError(...args); | ||||
|         } | ||||
|     }); | ||||
|     vi.spyOn(console, 'warn').mockImplementation((...args) => { | ||||
|         if (!shouldIgnore(warningsToIgnore, args)) { | ||||
|             consoleWarn(...args); | ||||
|         } | ||||
|     }); | ||||
|     vi.spyOn(console, 'log').mockImplementation((...args) => { | ||||
|         if (!shouldIgnore(logsToIgnore, args)) { | ||||
|             consoleLog(...args); | ||||
|         } | ||||
|     }); | ||||
| }); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user