From 3dbbaa4b908b43b0be66be614bb745c358196d68 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Sat, 5 Dec 2020 17:49:22 +0300 Subject: [PATCH 1/9] test: static output --- client-src/default/webpack.config.js | 4 +- client-src/sockjs/webpack.config.js | 4 +- .../transpiled-modules/webpack.config.js | 3 +- test/cli/__snapshots__/cli.test.js.snap | 12 ++-- test/cli/cli.test.js | 58 +++++++++++++------ test/fixtures/static/foo.js | 3 + test/fixtures/static/static/index.html | 15 +++++ test/fixtures/static/webpack.config.js | 11 ++++ test/helpers/test-bin.js | 7 +-- 9 files changed, 87 insertions(+), 30 deletions(-) create mode 100644 test/fixtures/static/foo.js create mode 100644 test/fixtures/static/static/index.html create mode 100644 test/fixtures/static/webpack.config.js diff --git a/client-src/default/webpack.config.js b/client-src/default/webpack.config.js index 20f0d1d76b..f63160971f 100644 --- a/client-src/default/webpack.config.js +++ b/client-src/default/webpack.config.js @@ -1,6 +1,7 @@ 'use strict'; const path = require('path'); +const webpack = require('webpack'); module.exports = { mode: 'production', @@ -9,7 +10,8 @@ module.exports = { path: path.resolve(__dirname, '../../client/default'), filename: 'index.bundle.js', }, - target: ['web', 'es5'], + // Workaround for webpack@4 installation + target: webpack.webpack ? ['web', 'es5'] : 'web', module: { rules: [ { diff --git a/client-src/sockjs/webpack.config.js b/client-src/sockjs/webpack.config.js index e4c3bd347a..07cd5a18df 100644 --- a/client-src/sockjs/webpack.config.js +++ b/client-src/sockjs/webpack.config.js @@ -1,6 +1,7 @@ 'use strict'; const path = require('path'); +const webpack = require('webpack'); module.exports = { mode: 'production', @@ -11,5 +12,6 @@ module.exports = { library: 'SockJS', libraryTarget: 'umd', }, - target: ['web', 'es5'], + // Workaround for webpack@4 installation + target: webpack.webpack ? ['web', 'es5'] : 'web', }; diff --git a/client-src/transpiled-modules/webpack.config.js b/client-src/transpiled-modules/webpack.config.js index a445f08116..2fd5625d16 100644 --- a/client-src/transpiled-modules/webpack.config.js +++ b/client-src/transpiled-modules/webpack.config.js @@ -1,6 +1,7 @@ 'use strict'; const path = require('path'); +const webpack = require('webpack'); const { merge } = require('webpack-merge'); const base = { @@ -9,7 +10,7 @@ const base = { path: path.resolve(__dirname, '../../client/transpiled-modules'), libraryTarget: 'commonjs2', }, - target: ['web', 'es5'], + target: webpack.webpack ? ['web', 'es5'] : 'web', module: { rules: [ { diff --git a/test/cli/__snapshots__/cli.test.js.snap b/test/cli/__snapshots__/cli.test.js.snap index 2e31ea80d0..372eeae3b4 100644 --- a/test/cli/__snapshots__/cli.test.js.snap +++ b/test/cli/__snapshots__/cli.test.js.snap @@ -2,6 +2,7 @@ exports[`CLI --hot webpack 4 1`] = ` " [webpack-dev-server] Project is running at http://localhost:8080/ + [webpack-dev-server] Content not from webpack x.x.x served from 'Xdir/static' directory [webpack-dev-middleware] Hash: X Version: webpack x.x.x Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT @@ -16,19 +17,20 @@ exports[`CLI --hot webpack 4 1`] = ` [../../../client/default/utils/log.js] Xdir/client/default/utils/log.js X bytes {main} [built] [../../../client/default/utils/reloadApp.js] Xdir/client/default/utils/reloadApp.js X KiB {main} [built] [../../../client/default/utils/sendMessage.js] Xdir/client/default/utils/sendMessage.js X bytes {main} [built] - [../../../client/transpiled-modules/strip-ansi.js] Xdir/client/transpiled-modules/strip-ansi.js X bytes {main} [built] + [../../../client/transpiled-modules/strip-ansi.js] Xdir/client/transpiled-modules/strip-ansi.js X KiB {main} [built] [../../../node_modules/webpack/hot sync ^\\\\.\\\\/log$] (webpack)/hot sync nonrecursive ^\\\\.\\\\/log$ X bytes {main} [built] [../../../node_modules/webpack/hot/dev-server.js] (webpack)/hot/dev-server.js X KiB {main} [built] [../../../node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js X bytes {main} [built] [../../../node_modules/webpack/hot/log-apply-result.js] (webpack)/hot/log-apply-result.js X KiB {main} [built] [../../../node_modules/webpack/hot/log.js] (webpack)/hot/log.js X KiB {main} [built] [./foo.js] X bytes {main} [built] - + 19 hidden modules + + 18 hidden modules [webpack-dev-middleware] Compiled successfully." `; exports[`CLI --hot webpack 5 1`] = ` " [webpack-dev-server] Project is running at http://localhost:8080/ + [webpack-dev-server] Content not from webpack x.x.x served from 'Xdir/static' directory [webpack-dev-middleware] asset main.js X KiB [emitted] (name: main) runtime modules X KiB 10 modules cacheable modules X KiB @@ -47,6 +49,7 @@ exports[`CLI --hot webpack 5 1`] = ` exports[`CLI --no-hot webpack 4 1`] = ` " [webpack-dev-server] Project is running at http://localhost:8080/ + [webpack-dev-server] Content not from webpack x.x.x served from 'Xdir/static' directory [webpack-dev-middleware] Hash: X Version: webpack x.x.x Time: Xms Built at: Thu Jan 01 1970 00:00:00 GMT @@ -64,16 +67,17 @@ exports[`CLI --no-hot webpack 4 1`] = ` [../../../client/default/utils/reloadApp.js] Xdir/client/default/utils/reloadApp.js X KiB {main} [built] [../../../client/default/utils/sendMessage.js] Xdir/client/default/utils/sendMessage.js X bytes {main} [built] [../../../client/transpiled-modules/log.js] Xdir/client/transpiled-modules/log.js X KiB {main} [built] - [../../../client/transpiled-modules/strip-ansi.js] Xdir/client/transpiled-modules/strip-ansi.js X bytes {main} [built] + [../../../client/transpiled-modules/strip-ansi.js] Xdir/client/transpiled-modules/strip-ansi.js X KiB {main} [built] [../../../node_modules/ansi-html/index.js] Xdir/node_modules/ansi-html/index.js X KiB {main} [built] [../../../node_modules/webpack/hot sync ^\\\\.\\\\/log$] (webpack)/hot sync nonrecursive ^\\\\.\\\\/log$ X bytes {main} [built] [./foo.js] X bytes {main} [built] - + 17 hidden modules + + 16 hidden modules [webpack-dev-middleware] Compiled successfully." `; exports[`CLI --no-hot webpack 5 1`] = ` " [webpack-dev-server] Project is running at http://localhost:8080/ + [webpack-dev-server] Content not from webpack x.x.x served from 'Xdir/static' directory [webpack-dev-middleware] asset main.js X KiB [emitted] (name: main) runtime modules X bytes 3 modules cacheable modules X KiB diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index 48c5ddbcc0..9d6ff77c93 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -1,6 +1,6 @@ 'use strict'; -const { join, resolve } = require('path'); +const path = require('path'); const execa = require('execa'); const internalIp = require('internal-ip'); const testBin = require('../helpers/test-bin'); @@ -10,10 +10,9 @@ const isWebpack5 = require('../helpers/isWebpack5'); let runCLITest = describe; let basePath; try { - basePath = join(require.resolve('webpack-dev-server'), '..', '..').replace( - /\\/g, - '/' - ); + basePath = path + .join(require.resolve('webpack-dev-server'), '..', '..') + .replace(/\\/g, '/'); } catch { runCLITest = describe.skip; } @@ -178,7 +177,7 @@ runCLITest('CLI', () => { it('should log public path', (done) => { testBin( false, - resolve(__dirname, '../fixtures/dev-public-path/webpack.config.js') + path.resolve(__dirname, '../fixtures/dev-public-path/webpack.config.js') ) .then((output) => { expect(output.exitCode).toEqual(0); @@ -194,10 +193,35 @@ runCLITest('CLI', () => { }); }); + it('should log static', (done) => { + testBin( + false, + path.resolve(__dirname, '../fixtures/static/webpack.config.js') + ) + .then((output) => { + console.log(output); + expect(output.exitCode).toEqual(0); + done(); + }) + .catch((err) => { + const staticDirectory = path.resolve( + __dirname, + '../fixtures/static/static' + ); + + // for windows + expect(err.stderr).toContain( + `Content not from webpack is served from '${staticDirectory}' directory` + ); + expect(err.stderr).toContain('Compiled successfully.'); + done(); + }); + }); + it('should accept the promise function of webpack.config.js', (done) => { testBin( false, - resolve(__dirname, '../fixtures/promise-config/webpack.config.js') + path.resolve(__dirname, '../fixtures/promise-config/webpack.config.js') ) .then((output) => { expect(output.exitCode).toEqual(0); @@ -211,8 +235,8 @@ runCLITest('CLI', () => { }); it('should exit the process when SIGINT is detected', (done) => { - const cliPath = resolve(__dirname, '../../bin/webpack-dev-server.js'); - const examplePath = resolve(__dirname, '../../examples/cli/public'); + const cliPath = path.resolve(__dirname, '../../bin/webpack-dev-server.js'); + const examplePath = path.resolve(__dirname, '../../examples/cli/public'); const cp = execa('node', [cliPath], { cwd: examplePath }); cp.stderr.on('data', (data) => { @@ -231,8 +255,8 @@ runCLITest('CLI', () => { }); it('should exit the process when SIGINT is detected, even before the compilation is done', (done) => { - const cliPath = resolve(__dirname, '../../bin/webpack-dev-server.js'); - const cwd = resolve(__dirname, '../fixtures/cli'); + const cliPath = path.resolve(__dirname, '../../bin/webpack-dev-server.js'); + const cwd = path.resolve(__dirname, '../fixtures/cli'); const cp = execa('node', [cliPath], { cwd }); let killed = false; @@ -253,8 +277,8 @@ runCLITest('CLI', () => { }); it('should exit the process when stdin ends if --stdin', (done) => { - const cliPath = resolve(__dirname, '../../bin/webpack-dev-server.js'); - const examplePath = resolve(__dirname, '../../examples/cli/public'); + const cliPath = path.resolve(__dirname, '../../bin/webpack-dev-server.js'); + const examplePath = path.resolve(__dirname, '../../examples/cli/public'); const cp = execa('node', [cliPath, '--stdin'], { cwd: examplePath }); cp.stderr.on('data', (data) => { @@ -274,8 +298,8 @@ runCLITest('CLI', () => { }); it('should exit the process when stdin ends if --stdin, even before the compilation is done', (done) => { - const cliPath = resolve(__dirname, '../../bin/webpack-dev-server.js'); - const cwd = resolve(__dirname, '../fixtures/cli'); + const cliPath = path.resolve(__dirname, '../../bin/webpack-dev-server.js'); + const cwd = path.resolve(__dirname, '../fixtures/cli'); const cp = execa('node', [cliPath, '--stdin'], { cwd }); let killed = false; @@ -299,8 +323,8 @@ runCLITest('CLI', () => { // TODO: do not skip after @webpack-cli/serve passes null port by default // https://github.com/webpack/webpack-cli/pull/2126 it.skip('should use different random port when multiple instances are started on different processes', (done) => { - const cliPath = resolve(__dirname, '../../bin/webpack-dev-server.js'); - const cwd = resolve(__dirname, '../fixtures/cli'); + const cliPath = path.resolve(__dirname, '../../bin/webpack-dev-server.js'); + const cwd = path.resolve(__dirname, '../fixtures/cli'); const cp = execa('node', [cliPath, '--colors=false'], { cwd }); const cp2 = execa('node', [cliPath, '--colors=false'], { cwd }); diff --git a/test/fixtures/static/foo.js b/test/fixtures/static/foo.js new file mode 100644 index 0000000000..f88d8b5040 --- /dev/null +++ b/test/fixtures/static/foo.js @@ -0,0 +1,3 @@ +'use strict'; + +console.log('i am foo!'); diff --git a/test/fixtures/static/static/index.html b/test/fixtures/static/static/index.html new file mode 100644 index 0000000000..3a990c0653 --- /dev/null +++ b/test/fixtures/static/static/index.html @@ -0,0 +1,15 @@ + + + + + + + Document + + + Test + + diff --git a/test/fixtures/static/webpack.config.js b/test/fixtures/static/webpack.config.js new file mode 100644 index 0000000000..2ddf10925d --- /dev/null +++ b/test/fixtures/static/webpack.config.js @@ -0,0 +1,11 @@ +'use strict'; + +const path = require('path'); + +module.exports = { + mode: 'development', + entry: path.resolve(__dirname, 'foo.js'), + devServer: { + static: path.resolve(__dirname, 'static'), + }, +}; diff --git a/test/helpers/test-bin.js b/test/helpers/test-bin.js index a57da3dd3a..25e3af020a 100644 --- a/test/helpers/test-bin.js +++ b/test/helpers/test-bin.js @@ -26,12 +26,7 @@ function testBin(testArgs, configPath) { testArgs = testArgs.split(' '); } - const args = [ - webpackDevServerPath, - '--config', - configPath, - '--no-static', - ].concat(testArgs); + const args = [webpackDevServerPath, '--config', configPath].concat(testArgs); return execa('node', args, { cwd, env, timeout: 10000 }); } From c19a6dde906cdbddc394f034e78385bdc59609b3 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Sat, 5 Dec 2020 18:04:38 +0300 Subject: [PATCH 2/9] test: fix snapshot --- test/cli/__snapshots__/cli.test.js.snap | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/cli/__snapshots__/cli.test.js.snap b/test/cli/__snapshots__/cli.test.js.snap index 372eeae3b4..375741bfc0 100644 --- a/test/cli/__snapshots__/cli.test.js.snap +++ b/test/cli/__snapshots__/cli.test.js.snap @@ -17,14 +17,14 @@ exports[`CLI --hot webpack 4 1`] = ` [../../../client/default/utils/log.js] Xdir/client/default/utils/log.js X bytes {main} [built] [../../../client/default/utils/reloadApp.js] Xdir/client/default/utils/reloadApp.js X KiB {main} [built] [../../../client/default/utils/sendMessage.js] Xdir/client/default/utils/sendMessage.js X bytes {main} [built] - [../../../client/transpiled-modules/strip-ansi.js] Xdir/client/transpiled-modules/strip-ansi.js X KiB {main} [built] + [../../../client/transpiled-modules/strip-ansi.js] Xdir/client/transpiled-modules/strip-ansi.js X bytes {main} [built] [../../../node_modules/webpack/hot sync ^\\\\.\\\\/log$] (webpack)/hot sync nonrecursive ^\\\\.\\\\/log$ X bytes {main} [built] [../../../node_modules/webpack/hot/dev-server.js] (webpack)/hot/dev-server.js X KiB {main} [built] [../../../node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js X bytes {main} [built] [../../../node_modules/webpack/hot/log-apply-result.js] (webpack)/hot/log-apply-result.js X KiB {main} [built] [../../../node_modules/webpack/hot/log.js] (webpack)/hot/log.js X KiB {main} [built] [./foo.js] X bytes {main} [built] - + 18 hidden modules + + 19 hidden modules [webpack-dev-middleware] Compiled successfully." `; @@ -67,11 +67,11 @@ exports[`CLI --no-hot webpack 4 1`] = ` [../../../client/default/utils/reloadApp.js] Xdir/client/default/utils/reloadApp.js X KiB {main} [built] [../../../client/default/utils/sendMessage.js] Xdir/client/default/utils/sendMessage.js X bytes {main} [built] [../../../client/transpiled-modules/log.js] Xdir/client/transpiled-modules/log.js X KiB {main} [built] - [../../../client/transpiled-modules/strip-ansi.js] Xdir/client/transpiled-modules/strip-ansi.js X KiB {main} [built] + [../../../client/transpiled-modules/strip-ansi.js] Xdir/client/transpiled-modules/strip-ansi.js X bytes {main} [built] [../../../node_modules/ansi-html/index.js] Xdir/node_modules/ansi-html/index.js X KiB {main} [built] [../../../node_modules/webpack/hot sync ^\\\\.\\\\/log$] (webpack)/hot sync nonrecursive ^\\\\.\\\\/log$ X bytes {main} [built] [./foo.js] X bytes {main} [built] - + 16 hidden modules + + 17 hidden modules [webpack-dev-middleware] Compiled successfully." `; From 47ecf31df506042932092dae17bb42226db67d84 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Sat, 5 Dec 2020 18:19:11 +0300 Subject: [PATCH 3/9] test: fix --- test/cli/cli.test.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index 9d6ff77c93..f59ec60570 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -10,9 +10,7 @@ const isWebpack5 = require('../helpers/isWebpack5'); let runCLITest = describe; let basePath; try { - basePath = path - .join(require.resolve('webpack-dev-server'), '..', '..') - .replace(/\\/g, '/'); + basePath = path.join(require.resolve('webpack-dev-server'), '..', '..'); } catch { runCLITest = describe.skip; } From 4864f9d47efc4d2d6bfcc78c447201bd8c12223b Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Mon, 7 Dec 2020 14:14:01 +0300 Subject: [PATCH 4/9] test: fix --- test/cli/cli.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index f59ec60570..aa2e0263a2 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -36,7 +36,7 @@ runCLITest('CLI', () => { '$1 Thu Jan 01 1970 00:00:00 GMT' ) .replace(/webpack [^ )]+/g, 'webpack x.x.x') - .replace(new RegExp(quotemeta(basePath), 'g'), 'Xdir') + .replace(new RegExp(`${quotemeta(basePath)}(/|\\)`, 'g'), '/Xdir') .replace(/(Hash:) [a-z0-9]+/g, '$1 X') .replace(/ dependencies:Xms/g, '') .replace(/, additional resolving: X ms/g, ''); From ed9775f5225323cc8d48ac1a5d0cf5e354499055 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Mon, 7 Dec 2020 14:14:15 +0300 Subject: [PATCH 5/9] test: fix --- test/cli/cli.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index aa2e0263a2..35e9243bb1 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -36,7 +36,7 @@ runCLITest('CLI', () => { '$1 Thu Jan 01 1970 00:00:00 GMT' ) .replace(/webpack [^ )]+/g, 'webpack x.x.x') - .replace(new RegExp(`${quotemeta(basePath)}(/|\\)`, 'g'), '/Xdir') + .replace(new RegExp(`${quotemeta(basePath)}(/|\\)`, 'g'), '/Xdir/') .replace(/(Hash:) [a-z0-9]+/g, '$1 X') .replace(/ dependencies:Xms/g, '') .replace(/, additional resolving: X ms/g, ''); From 240d580495a916657aca46e17a05e951af99b5af Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Mon, 7 Dec 2020 14:23:09 +0300 Subject: [PATCH 6/9] test: fix --- test/cli/cli.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index 35e9243bb1..cf18820a7e 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -36,7 +36,8 @@ runCLITest('CLI', () => { '$1 Thu Jan 01 1970 00:00:00 GMT' ) .replace(/webpack [^ )]+/g, 'webpack x.x.x') - .replace(new RegExp(`${quotemeta(basePath)}(/|\\)`, 'g'), '/Xdir/') + .replace(new RegExp(quotemeta(basePath), 'g'), 'Xdir') + .replace(/[\\/]static/, '/static') .replace(/(Hash:) [a-z0-9]+/g, '$1 X') .replace(/ dependencies:Xms/g, '') .replace(/, additional resolving: X ms/g, ''); From 824a5c8751f9ff735867c986b00d936fb38a8583 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Mon, 7 Dec 2020 14:51:27 +0300 Subject: [PATCH 7/9] test: fix --- test/cli/cli.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index cf18820a7e..a03e7f14a8 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -36,7 +36,7 @@ runCLITest('CLI', () => { '$1 Thu Jan 01 1970 00:00:00 GMT' ) .replace(/webpack [^ )]+/g, 'webpack x.x.x') - .replace(new RegExp(quotemeta(basePath), 'g'), 'Xdir') + .replace(new RegExp(quotemeta(basePath.replace(/\\/g, '/')), 'g'), 'Xdir') .replace(/[\\/]static/, '/static') .replace(/(Hash:) [a-z0-9]+/g, '$1 X') .replace(/ dependencies:Xms/g, '') From 8a5b2ca981270d7826af3b4cdde5b98683f04b27 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Mon, 7 Dec 2020 15:03:10 +0300 Subject: [PATCH 8/9] test: fix --- test/cli/cli.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index a03e7f14a8..d415334f8e 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -10,7 +10,9 @@ const isWebpack5 = require('../helpers/isWebpack5'); let runCLITest = describe; let basePath; try { - basePath = path.join(require.resolve('webpack-dev-server'), '..', '..'); + basePath = path + .join(require.resolve('webpack-dev-server'), '..', '..') + .replace(/\\/g, '/'); } catch { runCLITest = describe.skip; } @@ -36,7 +38,7 @@ runCLITest('CLI', () => { '$1 Thu Jan 01 1970 00:00:00 GMT' ) .replace(/webpack [^ )]+/g, 'webpack x.x.x') - .replace(new RegExp(quotemeta(basePath.replace(/\\/g, '/')), 'g'), 'Xdir') + .replace(new RegExp(quotemeta(basePath), 'g'), 'Xdir') .replace(/[\\/]static/, '/static') .replace(/(Hash:) [a-z0-9]+/g, '$1 X') .replace(/ dependencies:Xms/g, '') From 6b0ceb22e9e28e9d3343640406394c3253f119ae Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Mon, 7 Dec 2020 15:24:34 +0300 Subject: [PATCH 9/9] test: fix --- test/cli/cli.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index d415334f8e..10ece79d67 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -9,10 +9,9 @@ const isWebpack5 = require('../helpers/isWebpack5'); // skip if webpack-dev-server is not linked let runCLITest = describe; let basePath; + try { - basePath = path - .join(require.resolve('webpack-dev-server'), '..', '..') - .replace(/\\/g, '/'); + basePath = path.join(require.resolve('webpack-dev-server'), '..', '..'); } catch { runCLITest = describe.skip; } @@ -38,6 +37,7 @@ runCLITest('CLI', () => { '$1 Thu Jan 01 1970 00:00:00 GMT' ) .replace(/webpack [^ )]+/g, 'webpack x.x.x') + .replace(new RegExp(quotemeta(basePath.replace(/\\/g, '/')), 'g'), 'Xdir') .replace(new RegExp(quotemeta(basePath), 'g'), 'Xdir') .replace(/[\\/]static/, '/static') .replace(/(Hash:) [a-z0-9]+/g, '$1 X')