Skip to content

Commit b819ef3

Browse files
committed
test: fix
1 parent 1d0af64 commit b819ef3

File tree

3 files changed

+8
-69
lines changed

3 files changed

+8
-69
lines changed

test/cli/__snapshots__/cli.test.js.snap

-39
This file was deleted.

test/cli/cli.test.js

+4-30
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const isWebpack5 = require('../helpers/isWebpack5');
88

99
// skip if webpack-dev-server is not linked
1010
let runCLITest = describe;
11-
let basePath;
1211

1312
try {
1413
basePath = path.join(require.resolve('webpack-dev-server'), '..', '..');
@@ -17,31 +16,6 @@ try {
1716
}
1817

1918
runCLITest('CLI', () => {
20-
/* Based on webpack/test/StatsTestCases.test.js */
21-
/**
22-
* Escapes regular expression metacharacters
23-
* @param {string} str String to quote
24-
* @returns {string} Escaped string
25-
*/
26-
const quotemeta = (str) => str.replace(/[-[\]\\/{}()*+?.^$|]/g, '\\$&');
27-
28-
const normalizeOutput = (output) =>
29-
output
30-
// eslint-disable-next-line no-control-regex
31-
.replace(/\u001b\[[0-9;]*m/g, '')
32-
.replace(/[.0-9]+(\s?)(ms|KiB|bytes)/g, 'X$1$2')
33-
.replace(
34-
/(Built at:) (.*)$/gm,
35-
'$1 Thu Jan 01 1970 <CLR=BOLD>00:00:00</CLR> GMT'
36-
)
37-
.replace(/webpack [^ )]+/g, 'webpack x.x.x')
38-
.replace(new RegExp(quotemeta(basePath.replace(/\\/g, '/')), 'g'), 'Xdir')
39-
.replace(new RegExp(quotemeta(basePath), 'g'), 'Xdir')
40-
.replace(/[\\/]public/, '/public')
41-
.replace(/(Hash:) [a-z0-9]+/g, '$1 X')
42-
.replace(/ dependencies:Xms/g, '')
43-
.replace(/, additional resolving: X ms/g, '');
44-
4519
const webpack4Test = isWebpack5 ? it.skip : it;
4620
const webpack5Test = isWebpack5 ? it : it.skip;
4721

@@ -66,20 +40,20 @@ runCLITest('CLI', () => {
6640
});
6741

6842
webpack5Test('--hot webpack 5', (done) => {
69-
testBin('--hot')
43+
testBin('--hot', path.resolve(__dirname, '../fixtures/cli/verbose-config.js'))
7044
.then((output) => {
7145
expect(output.exitCode).toEqual(0);
72-
expect(normalizeOutput(output.stderr)).toMatchSnapshot();
46+
expect(output.stderr).toContain('webpack/runtime/hot module replacement');
7347
done();
7448
})
7549
.catch(done);
7650
});
7751

7852
webpack5Test('--no-hot webpack 5', (done) => {
79-
testBin('--no-hot')
53+
testBin('--no-hot', path.resolve(__dirname, '../fixtures/cli/verbose-config.js'))
8054
.then((output) => {
8155
expect(output.exitCode).toEqual(0);
82-
expect(normalizeOutput(output.stderr)).toMatchSnapshot();
56+
expect(output.stderr).not.toContain('webpack/runtime/hot module replacement');
8357
done();
8458
})
8559
.catch(done);

test/fixtures/cli/verbose-config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
stats: 'verbose',
3+
mode: 'development'
4+
}

0 commit comments

Comments
 (0)