@@ -14,9 +14,10 @@ const outputDir = path.join(__dirname, "output/cache");
14
14
const babelLoader = path . join ( __dirname , "../lib" ) ;
15
15
16
16
const globalConfig = {
17
+ mode : "development" ,
17
18
entry : path . join ( __dirname , "fixtures/basic.js" ) ,
18
19
module : {
19
- loaders : [
20
+ rules : [
20
21
{
21
22
test : / \. j s $ / ,
22
23
loader : babelLoader ,
@@ -53,12 +54,12 @@ test.cb("should output files to cache directory", t => {
53
54
path : t . context . directory ,
54
55
} ,
55
56
module : {
56
- loaders : [
57
+ rules : [
57
58
{
58
59
test : / \. j s $ / ,
59
60
loader : babelLoader ,
60
61
exclude : / n o d e _ m o d u l e s / ,
61
- query : {
62
+ options : {
62
63
cacheDirectory : t . context . cacheDirectory ,
63
64
presets : [ "env" ] ,
64
65
} ,
@@ -67,8 +68,10 @@ test.cb("should output files to cache directory", t => {
67
68
} ,
68
69
} ) ;
69
70
70
- webpack ( config , err => {
71
+ webpack ( config , ( err , stats ) => {
71
72
t . is ( err , null ) ;
73
+ t . is ( stats . compilation . errors . length , 0 ) ;
74
+ t . is ( stats . compilation . warnings . length , 0 ) ;
72
75
73
76
fs . readdir ( t . context . cacheDirectory , ( err , files ) => {
74
77
t . is ( err , null ) ;
@@ -86,12 +89,12 @@ test.cb.serial(
86
89
path : t . context . directory ,
87
90
} ,
88
91
module : {
89
- loaders : [
92
+ rules : [
90
93
{
91
94
test : / \. j s x ? / ,
92
95
loader : babelLoader ,
93
96
exclude : / n o d e _ m o d u l e s / ,
94
- query : {
97
+ options : {
95
98
cacheDirectory : true ,
96
99
presets : [ "env" ] ,
97
100
} ,
@@ -100,8 +103,10 @@ test.cb.serial(
100
103
} ,
101
104
} ) ;
102
105
103
- webpack ( config , err => {
106
+ webpack ( config , ( err , stats ) => {
104
107
t . is ( err , null ) ;
108
+ t . is ( stats . compilation . errors . length , 0 ) ;
109
+ t . is ( stats . compilation . warnings . length , 0 ) ;
105
110
106
111
fs . readdir ( defaultCacheDir , ( err , files ) => {
107
112
files = files . filter ( file => / \b [ 0 - 9 a - f ] { 5 , 40 } \. j s o n \. g z \b / . test ( file ) ) ;
@@ -122,7 +127,7 @@ test.cb.serial(
122
127
path : t . context . directory ,
123
128
} ,
124
129
module : {
125
- loaders : [
130
+ rules : [
126
131
{
127
132
test : / \. j s x ? / ,
128
133
loader : `${ babelLoader } ?cacheDirectory=true&presets[]=env` ,
@@ -132,8 +137,10 @@ test.cb.serial(
132
137
} ,
133
138
} ) ;
134
139
135
- webpack ( config , err => {
140
+ webpack ( config , ( err , stats ) => {
136
141
t . is ( err , null ) ;
142
+ t . is ( stats . compilation . errors . length , 0 ) ;
143
+ t . is ( stats . compilation . warnings . length , 0 ) ;
137
144
138
145
fs . readdir ( defaultCacheDir , ( err , files ) => {
139
146
files = files . filter ( file => / \b [ 0 - 9 a - f ] { 5 , 40 } \. j s o n \. g z \b / . test ( file ) ) ;
@@ -152,12 +159,12 @@ test.cb.skip("should read from cache directory if cached file exists", t => {
152
159
path : t . context . directory ,
153
160
} ,
154
161
module : {
155
- loaders : [
162
+ rules : [
156
163
{
157
164
test : / \. j s x ? / ,
158
165
loader : babelLoader ,
159
166
exclude : / n o d e _ m o d u l e s / ,
160
- query : {
167
+ options : {
161
168
cacheDirectory : t . context . cacheDirectory ,
162
169
presets : [ "env" ] ,
163
170
} ,
@@ -168,8 +175,10 @@ test.cb.skip("should read from cache directory if cached file exists", t => {
168
175
169
176
// @TODO Find a way to know if the file as correctly read without relying on
170
177
// Istanbul for coverage.
171
- webpack ( config , err => {
178
+ webpack ( config , ( err , stats ) => {
172
179
t . is ( err , null ) ;
180
+ t . is ( stats . compilation . errors . length , 0 ) ;
181
+ t . is ( stats . compilation . warnings . length , 0 ) ;
173
182
174
183
webpack ( config , err => {
175
184
t . is ( err , null ) ;
@@ -188,12 +197,12 @@ test.cb("should have one file per module", t => {
188
197
path : t . context . directory ,
189
198
} ,
190
199
module : {
191
- loaders : [
200
+ rules : [
192
201
{
193
202
test : / \. j s x ? / ,
194
203
loader : babelLoader ,
195
204
exclude : / n o d e _ m o d u l e s / ,
196
- query : {
205
+ options : {
197
206
cacheDirectory : t . context . cacheDirectory ,
198
207
presets : [ "env" ] ,
199
208
} ,
@@ -202,8 +211,10 @@ test.cb("should have one file per module", t => {
202
211
} ,
203
212
} ) ;
204
213
205
- webpack ( config , err => {
214
+ webpack ( config , ( err , stats ) => {
206
215
t . is ( err , null ) ;
216
+ t . is ( stats . compilation . errors . length , 0 ) ;
217
+ t . is ( stats . compilation . warnings . length , 0 ) ;
207
218
208
219
fs . readdir ( t . context . cacheDirectory , ( err , files ) => {
209
220
t . is ( err , null ) ;
@@ -220,12 +231,12 @@ test.cb("should generate a new file if the identifier changes", t => {
220
231
path : t . context . directory ,
221
232
} ,
222
233
module : {
223
- loaders : [
234
+ rules : [
224
235
{
225
236
test : / \. j s x ? / ,
226
237
loader : babelLoader ,
227
238
exclude : / n o d e _ m o d u l e s / ,
228
- query : {
239
+ options : {
229
240
cacheDirectory : t . context . cacheDirectory ,
230
241
cacheIdentifier : "a" ,
231
242
presets : [ "env" ] ,
@@ -239,12 +250,12 @@ test.cb("should generate a new file if the identifier changes", t => {
239
250
path : t . context . directory ,
240
251
} ,
241
252
module : {
242
- loaders : [
253
+ rules : [
243
254
{
244
255
test : / \. j s x ? / ,
245
256
loader : babelLoader ,
246
257
exclude : / n o d e _ m o d u l e s / ,
247
- query : {
258
+ options : {
248
259
cacheDirectory : t . context . cacheDirectory ,
249
260
cacheIdentifier : "b" ,
250
261
presets : [ "env" ] ,
@@ -257,8 +268,10 @@ test.cb("should generate a new file if the identifier changes", t => {
257
268
let counter = configs . length ;
258
269
259
270
configs . forEach ( config => {
260
- webpack ( config , err => {
271
+ webpack ( config , ( err , stats ) => {
261
272
t . is ( err , null ) ;
273
+ t . is ( stats . compilation . errors . length , 0 ) ;
274
+ t . is ( stats . compilation . warnings . length , 0 ) ;
262
275
counter -= 1 ;
263
276
264
277
if ( ! counter ) {
@@ -280,12 +293,12 @@ test.cb("should allow to specify the .babelrc file", t => {
280
293
path : t . context . directory ,
281
294
} ,
282
295
module : {
283
- loaders : [
296
+ rules : [
284
297
{
285
298
test : / \. j s x ? / ,
286
299
loader : babelLoader ,
287
300
exclude : / n o d e _ m o d u l e s / ,
288
- query : {
301
+ options : {
289
302
cacheDirectory : t . context . cacheDirectory ,
290
303
babelrc : path . join ( __dirname , "fixtures/babelrc" ) ,
291
304
presets : [ "env" ] ,
@@ -300,12 +313,12 @@ test.cb("should allow to specify the .babelrc file", t => {
300
313
path : t . context . directory ,
301
314
} ,
302
315
module : {
303
- loaders : [
316
+ rules : [
304
317
{
305
318
test : / \. j s x ? / ,
306
319
loader : babelLoader ,
307
320
exclude : / n o d e _ m o d u l e s / ,
308
- query : {
321
+ options : {
309
322
cacheDirectory : t . context . cacheDirectory ,
310
323
presets : [ "env" ] ,
311
324
} ,
@@ -315,8 +328,12 @@ test.cb("should allow to specify the .babelrc file", t => {
315
328
} ) ,
316
329
] ;
317
330
318
- webpack ( config , err => {
331
+ webpack ( config , ( err , multiStats ) => {
319
332
t . is ( err , null ) ;
333
+ t . is ( multiStats . stats [ 0 ] . compilation . errors . length , 0 ) ;
334
+ t . is ( multiStats . stats [ 0 ] . compilation . warnings . length , 0 ) ;
335
+ t . is ( multiStats . stats [ 1 ] . compilation . errors . length , 0 ) ;
336
+ t . is ( multiStats . stats [ 1 ] . compilation . warnings . length , 0 ) ;
320
337
321
338
fs . readdir ( t . context . cacheDirectory , ( err , files ) => {
322
339
t . is ( err , null ) ;
0 commit comments