@@ -8,7 +8,6 @@ const isWebpack5 = require('../helpers/isWebpack5');
8
8
9
9
// skip if webpack-dev-server is not linked
10
10
let runCLITest = describe ;
11
- let basePath ;
12
11
13
12
try {
14
13
basePath = path . join ( require . resolve ( 'webpack-dev-server' ) , '..' , '..' ) ;
17
16
}
18
17
19
18
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 ? ) ( m s | K i B | b y t e s ) / g, 'X$1$2' )
33
- . replace (
34
- / ( B u i l t a t : ) ( .* ) $ / gm,
35
- '$1 Thu Jan 01 1970 <CLR=BOLD>00:00:00</CLR> GMT'
36
- )
37
- . replace ( / w e b p a c k [ ^ ) ] + / 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 ( / [ \\ / ] p u b l i c / , '/public' )
41
- . replace ( / ( H a s h : ) [ a - z 0 - 9 ] + / g, '$1 X' )
42
- . replace ( / d e p e n d e n c i e s : X m s / g, '' )
43
- . replace ( / , a d d i t i o n a l r e s o l v i n g : X m s / g, '' ) ;
44
-
45
19
const webpack4Test = isWebpack5 ? it . skip : it ;
46
20
const webpack5Test = isWebpack5 ? it : it . skip ;
47
21
@@ -66,20 +40,20 @@ runCLITest('CLI', () => {
66
40
} ) ;
67
41
68
42
webpack5Test ( '--hot webpack 5' , ( done ) => {
69
- testBin ( '--hot' )
43
+ testBin ( '--hot' , path . resolve ( __dirname , '../fixtures/cli/verbose-config.js' ) )
70
44
. then ( ( output ) => {
71
45
expect ( output . exitCode ) . toEqual ( 0 ) ;
72
- expect ( normalizeOutput ( output . stderr ) ) . toMatchSnapshot ( ) ;
46
+ expect ( output . stderr ) . toContain ( 'webpack/runtime/hot module replacement' ) ;
73
47
done ( ) ;
74
48
} )
75
49
. catch ( done ) ;
76
50
} ) ;
77
51
78
52
webpack5Test ( '--no-hot webpack 5' , ( done ) => {
79
- testBin ( '--no-hot' )
53
+ testBin ( '--no-hot' , path . resolve ( __dirname , '../fixtures/cli/verbose-config.js' ) )
80
54
. then ( ( output ) => {
81
55
expect ( output . exitCode ) . toEqual ( 0 ) ;
82
- expect ( normalizeOutput ( output . stderr ) ) . toMatchSnapshot ( ) ;
56
+ expect ( output . stderr ) . not . toContain ( 'webpack/runtime/hot module replacement' ) ;
83
57
done ( ) ;
84
58
} )
85
59
. catch ( done ) ;
0 commit comments