@@ -2,60 +2,14 @@ import '@testing-library/jest-dom';
22import { toHaveNoViolations } from 'jest-axe' ;
33import fetchMock from 'jest-fetch-mock' ;
44import { loadErrorMessages , loadDevMessages } from '@apollo/client/dev' ;
5-
6- function ignoreConsoleWarnings ( ) {
7- // Store the original console.warn
8- const originalWarn = console . warn ;
9-
10- // A list of warning messages to completely ignore
11- const warningsToIgnore = [
12- '[%s]: `%s` is deprecated and will be removed in Apollo Client 4.0. %s cache.diff canonizeResults Please remove this option.' ,
13- ] ;
14-
15- // Override console.warn
16- console . warn = ( ...args ) => {
17- // Check if the warning message includes any of our ignored strings
18- const shouldIgnore = warningsToIgnore . some ( ( ignoredMsg ) =>
19- args . join ( ' ' ) . includes ( ignoredMsg ) ,
20- ) ;
21-
22- // If it's one we want to ignore, do nothing (return early)
23- if ( shouldIgnore ) {
24- return ;
25- }
26-
27- // For all other warnings, call the original console.warn
28- originalWarn . apply ( console , args ) ;
29- } ;
30- }
31-
32- function ignoreConsoleErrors ( ) {
33- // Store the original console.error
34- const originalError = console . error ;
35-
36- // A list of error messages to completely ignore
37- const errorsToIgnore = [
38- 'Error: Could not parse CSS stylesheet' , // JSDOM cannot understand stylesheets generated by HDS-React.
39- ] ;
40-
41- // Override console.warn
42- console . error = ( ...args ) => {
43- // Check if the error message includes any of our ignored strings
44- const shouldIgnore = errorsToIgnore . some ( ( ignoredMsg ) =>
45- args . join ( ' ' ) . includes ( ignoredMsg ) ,
46- ) ;
47-
48- // If it's one we want to ignore, do nothing (return early)
49- if ( shouldIgnore ) {
50- return ;
51- }
52- // For all other warnings, call the original console.warn
53- originalError . apply ( console , args ) ;
54- } ;
55- }
56-
57- ignoreConsoleWarnings ( ) ;
58- ignoreConsoleErrors ( ) ;
5+ import { hideConsoleMessages } from './src/tests/hideConsoleMessages' ;
6+
7+ hideConsoleMessages ( {
8+ warn : [
9+ / ` c a n o n i z e R e s u l t s ` i s d e p r e c a t e d a n d w i l l b e r e m o v e d i n A p o l l o C l i e n t 4 .0 . P l e a s e r e m o v e t h i s o p t i o n ./ ,
10+ ] ,
11+ error : [ / C o u l d n o t p a r s e C S S s t y l e s h e e t / ] ,
12+ } ) ;
5913
6014fetchMock . enableMocks ( ) ;
6115
0 commit comments