@@ -94,4 +94,54 @@ describe('transportMode client', () => {
9494 } ) ;
9595 } ) ;
9696 } ) ;
97+
98+ describe ( 'unspecified port' , ( ) => {
99+ beforeAll ( ( done ) => {
100+ const options = {
101+ host : '0.0.0.0' ,
102+ hot : false ,
103+ client : { transport : 'sockjs' } ,
104+ webSocketServer : 'sockjs' ,
105+ } ;
106+ testServer . startAwaitingCompilation ( config , options , done ) ;
107+ } ) ;
108+
109+ describe ( 'on browser client' , ( ) => {
110+ it ( 'logs correctly' , ( done ) => {
111+ runBrowser ( ) . then ( ( { page, browser } ) => {
112+ const res = [ ] ;
113+ page . goto ( `http://localhost:8080/main` ) ;
114+ page . on ( 'console' , ( { _text } ) => {
115+ res . push ( _text ) ;
116+ } ) ;
117+
118+ page . waitForTimeout ( initConsoleDelay ) . then ( ( ) => {
119+ testServer . close ( ( ) => {
120+ // make sure the client gets the close message
121+ page . waitForTimeout ( awaitServerCloseDelay ) . then ( ( ) => {
122+ browser . close ( ) . then ( ( ) => {
123+ for ( let i = res . length - 1 ; i >= 0 ; i -- ) {
124+ if ( res [ i ] === '[webpack-dev-server] Disconnected!' ) {
125+ break ;
126+ } else if (
127+ res [ i ] === 'close' ||
128+ res [ i ] . includes ( 'net::ERR_CONNECTION_REFUSED' ) ||
129+ // this indicates a WebSocket Error object that was logged
130+ res [ i ] . includes ( 'JSHandle@object' )
131+ ) {
132+ // remove additional logging for the now failing connection,
133+ // since this could be a variable number of error messages
134+ res . splice ( i , 1 ) ;
135+ }
136+ }
137+ expect ( res ) . toMatchSnapshot ( ) ;
138+ done ( ) ;
139+ } ) ;
140+ } ) ;
141+ } ) ;
142+ } ) ;
143+ } ) ;
144+ } ) ;
145+ } ) ;
146+ } ) ;
97147} ) ;
0 commit comments