33/* eslint-disable
44 array-bracket-spacing,
55*/
6- const path = require ( 'path' ) ;
6+ const { unlink } = require ( 'fs' ) ;
7+ const { join, resolve } = require ( 'path' ) ;
78const execa = require ( 'execa' ) ;
89const runDevServer = require ( './helpers/run-webpack-dev-server' ) ;
910
10- const httpsCertificateDirectory = path . join (
11- __dirname ,
12- 'fixtures/https-certificate'
13- ) ;
14- const caPath = path . join ( httpsCertificateDirectory , 'ca.pem' ) ;
15- const pfxPath = path . join ( httpsCertificateDirectory , 'server.pfx' ) ;
16- const keyPath = path . join ( httpsCertificateDirectory , 'server.key' ) ;
17- const certPath = path . join ( httpsCertificateDirectory , 'server.crt' ) ;
11+ const httpsCertificateDirectory = join ( __dirname , 'fixtures/https-certificate' ) ;
12+ const caPath = join ( httpsCertificateDirectory , 'ca.pem' ) ;
13+ const pfxPath = join ( httpsCertificateDirectory , 'server.pfx' ) ;
14+ const keyPath = join ( httpsCertificateDirectory , 'server.key' ) ;
15+ const certPath = join ( httpsCertificateDirectory , 'server.crt' ) ;
1816
1917describe ( 'CLI' , ( ) => {
2018 it ( '--progress' , ( done ) => {
2119 runDevServer ( '--progress' )
2220 . then ( ( output ) => {
2321 expect ( output . code ) . toEqual ( 0 ) ;
24- expect ( output . stderr . indexOf ( '0% compiling' ) >= 0 ) . toBe ( true ) ;
22+ expect ( output . stderr . includes ( '0% compiling' ) ) . toBe ( true ) ;
2523 done ( ) ;
2624 } )
2725 . catch ( done ) ;
@@ -31,7 +29,7 @@ describe('CLI', () => {
3129 runDevServer ( '--bonjour' )
3230 . then ( ( output ) => {
3331 expect ( output . code ) . toEqual ( 0 ) ;
34- expect ( output . stdout . indexOf ( 'Bonjour' ) >= 0 ) . toBe ( true ) ;
32+ expect ( output . stdout . includes ( 'Bonjour' ) ) . toBe ( true ) ;
3533 done ( ) ;
3634 } )
3735 . catch ( done ) ;
@@ -41,7 +39,7 @@ describe('CLI', () => {
4139 runDevServer ( '--https' )
4240 . then ( ( output ) => {
4341 expect ( output . code ) . toEqual ( 0 ) ;
44- expect ( output . stdout . indexOf ( 'Project is running at' ) >= 0 ) . toBe ( true ) ;
42+ expect ( output . stdout . includes ( 'Project is running at' ) ) . toBe ( true ) ;
4543 done ( ) ;
4644 } )
4745 . catch ( done ) ;
@@ -53,7 +51,7 @@ describe('CLI', () => {
5351 )
5452 . then ( ( output ) => {
5553 expect ( output . code ) . toEqual ( 0 ) ;
56- expect ( output . stdout . indexOf ( 'Project is running at' ) >= 0 ) . toBe ( true ) ;
54+ expect ( output . stdout . includes ( 'Project is running at' ) ) . toBe ( true ) ;
5755 done ( ) ;
5856 } )
5957 . catch ( done ) ;
@@ -82,9 +80,29 @@ describe('CLI', () => {
8280 . catch ( done ) ;
8381 } ) ;
8482
83+ // The Unix socket to listen to (instead of a host).
84+ it ( '--socket' , ( done ) => {
85+ const socketPath = join ( '.' , 'webpack.sock' ) ;
86+
87+ runDevServer ( `--socket ${ socketPath } ` )
88+ . then ( ( output ) => {
89+ expect ( output . code ) . toEqual ( 0 ) ;
90+
91+ if ( process . platform === 'win32' ) {
92+ done ( ) ;
93+ } else {
94+ expect ( output . stdout . includes ( socketPath ) ) . toBe ( true ) ;
95+ unlink ( socketPath , ( ) => {
96+ done ( ) ;
97+ } ) ;
98+ }
99+ } )
100+ . catch ( done ) ;
101+ } ) ;
102+
85103 it ( 'should exit the process when SIGINT is detected' , ( done ) => {
86- const cliPath = path . resolve ( __dirname , '../bin/webpack-dev-server.js' ) ;
87- const examplePath = path . resolve ( __dirname , '../examples/cli/public' ) ;
104+ const cliPath = resolve ( __dirname , '../bin/webpack-dev-server.js' ) ;
105+ const examplePath = resolve ( __dirname , '../examples/cli/public' ) ;
88106 const cp = execa ( 'node' , [ cliPath ] , { cwd : examplePath } ) ;
89107
90108 cp . stdout . on ( 'data' , ( data ) => {
@@ -101,8 +119,8 @@ describe('CLI', () => {
101119 } ) ;
102120
103121 it ( 'should exit the process when SIGINT is detected, even before the compilation is done' , ( done ) => {
104- const cliPath = path . resolve ( __dirname , '../bin/webpack-dev-server.js' ) ;
105- const examplePath = path . resolve ( __dirname , '../examples/cli/public' ) ;
122+ const cliPath = resolve ( __dirname , '../bin/webpack-dev-server.js' ) ;
123+ const examplePath = resolve ( __dirname , '../examples/cli/public' ) ;
106124 const cp = execa ( 'node' , [ cliPath ] , { cwd : examplePath } ) ;
107125 let killed = false ;
108126
@@ -120,8 +138,8 @@ describe('CLI', () => {
120138 } ) ;
121139
122140 it ( 'should use different random port when multiple instances are started on different processes' , ( done ) => {
123- const cliPath = path . resolve ( __dirname , '../bin/webpack-dev-server.js' ) ;
124- const examplePath = path . resolve ( __dirname , '../examples/cli/public' ) ;
141+ const cliPath = resolve ( __dirname , '../bin/webpack-dev-server.js' ) ;
142+ const examplePath = resolve ( __dirname , '../examples/cli/public' ) ;
125143
126144 const cp = execa ( 'node' , [ cliPath ] , { cwd : examplePath } ) ;
127145 const cp2 = execa ( 'node' , [ cliPath ] , { cwd : examplePath } ) ;
0 commit comments