@@ -8,6 +8,7 @@ import createTestDirectory from "./helpers/createTestDirectory";
88const outputDir = path . join ( __dirname , "output/loader" ) ;
99const babelLoader = path . join ( __dirname , "../lib" ) ;
1010const globalConfig = {
11+ mode : "development" ,
1112 entry : path . join ( __dirname , "fixtures/basic.js" ) ,
1213 module : {
1314 rules : [
@@ -42,8 +43,10 @@ test.cb("should transpile the code snippet", t => {
4243 } ,
4344 } ) ;
4445
45- webpack ( config , err => {
46+ webpack ( config , ( err , stats ) => {
4647 t . is ( err , null ) ;
48+ t . is ( stats . compilation . errors . length , 0 ) ;
49+ t . is ( stats . compilation . warnings . length , 0 ) ;
4750
4851 fs . readdir ( t . context . directory , ( err , files ) => {
4952 t . is ( err , null ) ;
@@ -72,13 +75,15 @@ test.cb("should not throw error on syntax error", t => {
7275 webpack ( config , ( err , stats ) => {
7376 t . true ( stats . compilation . errors . length === 1 ) ;
7477 t . true ( stats . compilation . errors [ 0 ] instanceof Error ) ;
78+ t . is ( stats . compilation . warnings . length , 0 ) ;
7579
7680 t . end ( ) ;
7781 } ) ;
7882} ) ;
7983
8084test . cb ( "should use correct env" , t => {
8185 const config = {
86+ mode : "development" ,
8287 entry : path . join ( __dirname , "fixtures/basic.js" ) ,
8388 output : {
8489 path : t . context . directory ,
@@ -108,7 +113,8 @@ test.cb("should use correct env", t => {
108113 webpack ( config , ( err , stats ) => {
109114 t . is ( err , null ) ;
110115
111- t . true ( stats . compilation . errors . length === 1 ) ;
116+ t . is ( stats . compilation . errors . length , 1 ) ;
117+ t . is ( stats . compilation . warnings . length , 0 ) ;
112118
113119 t . truthy ( stats . compilation . errors [ 0 ] . message . match ( / e s 2 0 1 5 a b c / ) ) ;
114120 t . falsy ( stats . compilation . errors [ 0 ] . message . match ( / e s 2 0 1 5 x y z / ) ) ;
@@ -121,6 +127,7 @@ test.serial.cb("should not polute BABEL_ENV after using forceEnv", t => {
121127 const initialBabelEnv = process . env . BABEL_ENV ;
122128
123129 const config = {
130+ mode : "development" ,
124131 entry : path . join ( __dirname , "fixtures/basic.js" ) ,
125132 output : {
126133 path : t . context . directory ,
@@ -134,7 +141,7 @@ test.serial.cb("should not polute BABEL_ENV after using forceEnv", t => {
134141 forceEnv : "testenv" ,
135142 env : {
136143 testenv : {
137- presets : [ "es2015 " ] ,
144+ presets : [ "@babel/env " ] ,
138145 } ,
139146 } ,
140147 } ,
@@ -144,7 +151,9 @@ test.serial.cb("should not polute BABEL_ENV after using forceEnv", t => {
144151 } ,
145152 } ;
146153
147- webpack ( config , ( ) => {
154+ webpack ( config , ( err , stats ) => {
155+ t . is ( stats . compilation . errors . length , 0 ) ;
156+ t . is ( stats . compilation . warnings . length , 0 ) ;
148157 t . truthy ( process . env . BABEL_ENV === initialBabelEnv ) ;
149158 t . end ( ) ;
150159 } ) ;
@@ -156,6 +165,7 @@ test.serial.cb(
156165 const initialBabelEnv = process . env . BABEL_ENV ;
157166
158167 const config = {
168+ mode : "development" ,
159169 entry : path . join ( __dirname , "fixtures/basic.js" ) ,
160170 output : {
161171 path : t . context . directory ,
@@ -179,7 +189,11 @@ test.serial.cb(
179189 } ,
180190 } ;
181191
182- webpack ( config , ( ) => {
192+ webpack ( config , ( err , stats ) => {
193+ t . is ( err , null ) ;
194+ t . is ( stats . compilation . errors . length , 1 ) ;
195+ t . is ( stats . compilation . warnings . length , 0 ) ;
196+
183197 t . truthy ( process . env . BABEL_ENV === initialBabelEnv ) ;
184198 t . end ( ) ;
185199 } ) ;
@@ -192,6 +206,7 @@ test.serial.cb("should not change BABEL_ENV when using forceEnv", t => {
192206 process . env . BABEL_ENV = "nontestenv" ;
193207
194208 const config = {
209+ mode : "development" ,
195210 entry : path . join ( __dirname , "fixtures/basic.js" ) ,
196211 output : {
197212 path : t . context . directory ,
@@ -221,7 +236,8 @@ test.serial.cb("should not change BABEL_ENV when using forceEnv", t => {
221236 webpack ( config , ( err , stats ) => {
222237 t . is ( err , null ) ;
223238
224- t . true ( stats . compilation . errors . length === 1 ) ;
239+ t . is ( stats . compilation . errors . length , 1 ) ;
240+ t . is ( stats . compilation . warnings . length , 0 ) ;
225241
226242 t . truthy ( stats . compilation . errors [ 0 ] . message . match ( / e s 2 0 1 5 a b c / ) ) ;
227243 t . falsy ( stats . compilation . errors [ 0 ] . message . match ( / e s 2 0 1 5 x y z / ) ) ;
@@ -240,6 +256,7 @@ test.serial.cb("should not change BABEL_ENV when using forceEnv", t => {
240256
241257test . cb ( "should not throw without config" , t => {
242258 const config = {
259+ mode : "development" ,
243260 entry : path . join ( __dirname , "fixtures/basic.js" ) ,
244261 output : {
245262 path : t . context . directory ,
@@ -257,8 +274,8 @@ test.cb("should not throw without config", t => {
257274
258275 webpack ( config , ( err , stats ) => {
259276 t . is ( err , null ) ;
260-
261- t . true ( stats . compilation . errors . length === 0 ) ;
277+ t . is ( stats . compilation . errors . length , 0 ) ;
278+ t . is ( stats . compilation . warnings . length , 0 ) ;
262279
263280 t . end ( ) ;
264281 } ) ;
@@ -274,6 +291,8 @@ test.cb(
274291 } ,
275292 } ) ;
276293 webpack ( config , ( err , stats ) => {
294+ t . is ( err , null ) ;
295+ t . is ( stats . compilation . warnings . length , 0 ) ;
277296 const moduleBuildError = stats . compilation . errors [ 0 ] ;
278297 const babelLoaderError = moduleBuildError . error ;
279298 t . regex ( babelLoaderError . stack , / U n e x p e c t e d c h a r a c t e r / ) ;
0 commit comments