11'use strict' ;
2- const { existsSync } = require ( 'fs' ) ;
2+ const { existsSync, readFile } = require ( 'fs' ) ;
33const { resolve } = require ( 'path' ) ;
44const { run } = require ( '../../../utils/test-utils' ) ;
55
@@ -18,12 +18,17 @@ describe('function configuration', () => {
1818 // Should generate the appropriate files
1919 expect ( existsSync ( resolve ( __dirname , './bin/dev.js' ) ) ) . toBeTruthy ( ) ;
2020 } ) ;
21- it ( 'is able to understand multiple env flags' , ( ) => {
22- const { stderr, stdout } = run ( __dirname , [ '--env' , 'isDev' , '--env' , 'verboseStats' ] ) ;
21+ it ( 'is able to understand multiple env flags' , ( done ) => {
22+ const { stderr, stdout } = run ( __dirname , [ '--env' , 'isDev' , '--env' , 'verboseStats' , '--env' , 'envMessage' ] ) ;
2323 expect ( stderr ) . toBeFalsy ( ) ;
2424 expect ( stdout ) . toBeTruthy ( ) ;
25+ // check that the verbose env is respected
2526 expect ( stdout ) . toContain ( 'LOG from webpack.buildChunkGraph.visitModules' ) ;
26- // Should generate the appropriate files
27- expect ( existsSync ( resolve ( __dirname , './bin/dev.js' ) ) ) . toBeTruthy ( ) ;
27+ // check if the values from DefinePlugin make it to the compiled code
28+ readFile ( resolve ( __dirname , './bin/dev.js' ) , 'utf-8' , ( err , data ) => {
29+ expect ( err ) . toBe ( null ) ;
30+ expect ( data ) . toContain ( 'env message present' ) ;
31+ done ( ) ;
32+ } ) ;
2833 } ) ;
2934} ) ;
0 commit comments