@@ -94,7 +94,16 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => {
94
94
const webpackMiddlewareConfig = {
95
95
noInfo : true , // Hide webpack output because its noisy.
96
96
watchOptions : { poll : testConfig . poll } ,
97
- publicPath : '/_karma_webpack_/'
97
+ publicPath : '/_karma_webpack_/' ,
98
+ stats : { // Also prevent chunk and module display output, cleaner look. Only emit errors.
99
+ assets : false ,
100
+ colors : true ,
101
+ version : false ,
102
+ hash : false ,
103
+ timings : false ,
104
+ chunks : false ,
105
+ chunkModules : false
106
+ }
98
107
} ;
99
108
100
109
// If Karma is being ran in single run mode, throw errors.
@@ -156,15 +165,19 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => {
156
165
} ) ;
157
166
} ) ;
158
167
159
- compiler . plugin ( 'done' , ( ) => {
160
- emitter . refreshFiles ( ) ;
161
- isBlocked = false ;
162
- blocked . forEach ( ( cb ) => cb ( ) ) ;
163
- blocked = [ ] ;
168
+ compiler . plugin ( 'done' , ( stats : any ) => {
169
+ // Don't refresh karma when there are webpack errors.
170
+ if ( stats . compilation . errors . length === 0 ) {
171
+ emitter . refreshFiles ( ) ;
172
+ isBlocked = false ;
173
+ blocked . forEach ( ( cb ) => cb ( ) ) ;
174
+ blocked = [ ] ;
175
+ }
164
176
} ) ;
165
177
166
178
const middleware = new webpackDevMiddleware ( compiler , webpackMiddlewareConfig ) ;
167
179
180
+ // Forward requests to webpack server.
168
181
customFileHandlers . push ( {
169
182
urlRegex : / ^ \/ _ k a r m a _ w e b p a c k _ \/ .* / ,
170
183
handler : function handler ( req : any , res : any ) {
0 commit comments