@@ -3,7 +3,6 @@ const webpack = require('webpack');
33const HtmlPlugin = require ( 'html-webpack-plugin' ) ;
44
55const { isWebpack1 } = require ( '../lib/utils' ) ;
6- const webpackVersion = require ( '../lib/utils/get-webpack-version' ) ;
76const { loaderPath, fixturesPath } = require ( './_config' ) ;
87const {
98 rule,
@@ -75,7 +74,7 @@ describe('loader and plugin', () => {
7574
7675 it ( 'should warn if there is remaining loaders in extract mode' , async ( ) => {
7776 const v4Config = { } ;
78- if ( webpackVersion . IS_4 ) {
77+ if ( process . env . WEBPACK_VERSION === '4' ) {
7978 v4Config . mode = 'development' ;
8079 v4Config . devtool = false ;
8180 }
@@ -212,7 +211,7 @@ describe('loader and plugin', () => {
212211 const extractor = extractPlugin ( '[name].css' , { allChunks : true } ) ;
213212
214213 const v4Config = { } ;
215- if ( webpackVersion . IS_4 ) {
214+ if ( process . env . WEBPACK_VERSION === '4' ) {
216215 v4Config . mode = 'development' ;
217216 v4Config . devtool = false ;
218217 }
@@ -244,8 +243,8 @@ describe('loader and plugin', () => {
244243 assets [ 'entry2.css' ] . source ( ) . should . contain ( 'entry2.svg' ) ;
245244 } ) ;
246245
247- if ( ! webpackVersion . IS_4 ) {
248- it ( 'should work in combination with CommonsChunkPlugin' , async ( ) => {
246+ it ( 'should work in combination with CommonsChunkPlugin' , async ( ) => {
247+ try {
249248 const extractor = extractPlugin ( '[name].css' ) ;
250249 const { assets } = await compile ( {
251250 context : path . resolve ( fixturesPath , 'extract-text-webpack-plugin/with-commons-chunk-plugin' ) ,
@@ -268,8 +267,10 @@ describe('loader and plugin', () => {
268267 } ) ;
269268
270269 assets [ 'common.css' ] . source ( ) . should . contain ( 'common.svg' ) ;
271- } ) ;
272- }
270+ } catch ( e ) {
271+ e . message . should . contain ( 'webpack.optimize.CommonsChunkPlugin has been removed' ) ;
272+ }
273+ } ) ;
273274 } ) ;
274275
275276 describe ( 'html-loader interop' , ( ) => {
@@ -318,7 +319,7 @@ describe('loader and plugin', () => {
318319 } ) ;
319320
320321 // webpack 3 scope hoisting interop
321- if ( webpackVersion . IS_3 ) {
322+ if ( process . env . WEBPACK_VERSION === '3' ) {
322323 // eslint-disable-next-line global-require,import/no-unresolved
323324 const ModuleConcatenationPlugin = require ( 'webpack/lib/optimize/ModuleConcatenationPlugin' ) ;
324325
@@ -429,7 +430,7 @@ describe('loader and plugin', () => {
429430 const spriteFilename = defaultSpriteFilename ;
430431
431432 const v4Config = { } ;
432- if ( webpackVersion . IS_4 ) {
433+ if ( process . env . WEBPACK_VERSION === '4' ) {
433434 v4Config . mode = 'development' ;
434435 v4Config . devtool = false ;
435436 }
@@ -451,7 +452,7 @@ describe('loader and plugin', () => {
451452 const spriteFilename = defaultSpriteFilename ;
452453
453454 const v4Config = { } ;
454- if ( webpackVersion . IS_4 ) {
455+ if ( process . env . WEBPACK_VERSION === '4' ) {
455456 v4Config . mode = 'development' ;
456457 v4Config . devtool = false ;
457458 }
0 commit comments