@@ -24,6 +24,24 @@ jest.setTimeout(30000);
2424const concurrency = false ;
2525
2626describe ( 'optimize-plugin' , ( ) => {
27+ const $console = {
28+ log : console . log ,
29+ warn : console . warn ,
30+ info : console . info
31+ } ;
32+
33+ beforeAll ( ( ) => {
34+ console . warn = ( ) => 0 ;
35+ console . log = ( ) => 0 ;
36+ console . info = ( ) => 0 ;
37+ } ) ;
38+
39+ afterAll ( ( ) => {
40+ console . warn = $console . warn ;
41+ console . log = $console . log ;
42+ console . info = $console . info ;
43+ } ) ;
44+
2745 test ( 'exports a class' , ( ) => {
2846 expect ( OptimizePlugin ) . toBeInstanceOf ( Function ) ;
2947 expect ( OptimizePlugin . prototype ) . toHaveProperty ( 'apply' , expect . any ( Function ) ) ;
@@ -42,7 +60,7 @@ describe('optimize-plugin', () => {
4260 plugins : [
4361 new OptimizePlugin ( { concurrency } )
4462 ]
45- } ) ;
63+ } , $console ) ;
4664
4765 const assetNames = Object . keys ( stats . assets ) ;
4866 expect ( assetNames ) . toHaveLength ( 3 ) ;
@@ -61,7 +79,7 @@ describe('optimize-plugin', () => {
6179 expect ( polyfills ) . toMatch ( / O b j e c t \. d e f i n e P r o p e r t y / g) ;
6280 expect ( polyfills ) . not . toMatch ( / r e q u i r e \( / g) ;
6381
64- await printSizes ( stats . assets , '"it works"' ) ;
82+ await printSizes ( stats . assets , '"it works"' , $console ) ;
6583 } ) ;
6684
6785 test ( 'code splitting' , async ( ) => {
@@ -72,7 +90,7 @@ describe('optimize-plugin', () => {
7290 plugins : [
7391 new OptimizePlugin ( { concurrency } )
7492 ]
75- } ) ;
93+ } , $console ) ;
7694
7795 const assetNames = Object . keys ( stats . assets ) ;
7896 expect ( assetNames ) . toHaveLength ( 9 ) ;
@@ -97,7 +115,7 @@ describe('optimize-plugin', () => {
97115 expect ( polyfills ) . toMatch ( / O b j e c t \. d e f i n e P r o p e r t y / g) ;
98116 expect ( polyfills ) . not . toMatch ( / r e q u i r e \( / g) ;
99117
100- await printSizes ( stats . assets , 'code splitting' ) ;
118+ await printSizes ( stats . assets , 'code splitting' , $console ) ;
101119 } ) ;
102120
103121 describe ( 'TypeScript Support' , ( ) => {
@@ -120,7 +138,7 @@ describe('optimize-plugin', () => {
120138 plugins : [
121139 new OptimizePlugin ( { concurrency } )
122140 ]
123- } ) ;
141+ } , $console ) ;
124142
125143 const assetNames = Object . keys ( stats . assets ) ;
126144 expect ( assetNames ) . toHaveLength ( 3 ) ;
@@ -139,7 +157,7 @@ describe('optimize-plugin', () => {
139157 expect ( polyfills ) . toMatch ( / O b j e c t \. d e f i n e P r o p e r t y / g) ;
140158 expect ( polyfills ) . not . toMatch ( / r e q u i r e \( / g) ;
141159
142- await printSizes ( stats . assets , 'typescript support' ) ;
160+ await printSizes ( stats . assets , 'typescript support' , $console ) ;
143161 } ) ;
144162
145163 test ( 'using Sucrase' , async ( ) => {
@@ -158,7 +176,7 @@ describe('optimize-plugin', () => {
158176 plugins : [
159177 new OptimizePlugin ( { concurrency } )
160178 ]
161- } ) ;
179+ } , $console ) ;
162180
163181 const assetNames = Object . keys ( stats . assets ) ;
164182 expect ( assetNames ) . toHaveLength ( 3 ) ;
@@ -177,7 +195,7 @@ describe('optimize-plugin', () => {
177195 expect ( polyfills ) . toMatch ( / O b j e c t \. d e f i n e P r o p e r t y / g) ;
178196 expect ( polyfills ) . not . toMatch ( / r e q u i r e \( / g) ;
179197
180- await printSizes ( stats . assets , 'sucrase' ) ;
198+ await printSizes ( stats . assets , 'sucrase' , $console ) ;
181199 } ) ;
182200 } ) ;
183201} ) ;
0 commit comments