@@ -454,6 +454,99 @@ for (const webSocketServerType of webSocketServerTypes) {
454
454
} ) ;
455
455
} ) ;
456
456
457
+ describe ( 'should work when "port" option is "auto"' , ( ) => {
458
+ beforeAll ( ( done ) => {
459
+ const options = {
460
+ webSocketServer : webSocketServerType ,
461
+ port : 'auto' ,
462
+ host : '0.0.0.0' ,
463
+ } ;
464
+ testServer . startAwaitingCompilation ( config , options , done ) ;
465
+ } ) ;
466
+
467
+ afterAll ( testServer . close ) ;
468
+
469
+ describe ( 'browser client' , ( ) => {
470
+ it ( 'should work' , ( done ) => {
471
+ runBrowser ( ) . then ( ( { page, browser } ) => {
472
+ waitForTest ( browser , page , / w s / , ( websocketUrl ) => {
473
+ expect ( websocketUrl ) . toContain (
474
+ `${ websocketUrlProtocol } ://localhost:8080/ws`
475
+ ) ;
476
+
477
+ done ( ) ;
478
+ } ) ;
479
+
480
+ page . goto ( `http://localhost:8080/main` ) ;
481
+ } ) ;
482
+ } ) ;
483
+ } ) ;
484
+ } ) ;
485
+
486
+ describe ( 'should work when "host" option is IPv4' , ( ) => {
487
+ beforeAll ( ( done ) => {
488
+ const options = {
489
+ webSocketServer : webSocketServerType ,
490
+ port : port3 ,
491
+ host : internalIp . v4 . sync ( ) ,
492
+ } ;
493
+ testServer . startAwaitingCompilation ( config , options , done ) ;
494
+ } ) ;
495
+
496
+ afterAll ( testServer . close ) ;
497
+
498
+ describe ( 'browser client' , ( ) => {
499
+ it ( 'should work' , ( done ) => {
500
+ runBrowser ( ) . then ( ( { page, browser } ) => {
501
+ waitForTest ( browser , page , / w s / , ( websocketUrl ) => {
502
+ expect ( websocketUrl ) . toContain (
503
+ `${ websocketUrlProtocol } ://${ internalIp . v4 . sync ( ) } :${ port3 } /ws`
504
+ ) ;
505
+
506
+ done ( ) ;
507
+ } ) ;
508
+
509
+ page . goto ( `http://${ internalIp . v4 . sync ( ) } :${ port3 } /main` ) ;
510
+ } ) ;
511
+ } ) ;
512
+ } ) ;
513
+ } ) ;
514
+
515
+ describe ( 'should work with the "client.webSocketURL.port" option is 0' , ( ) => {
516
+ beforeAll ( ( done ) => {
517
+ const options = {
518
+ webSocketServer : webSocketServerType ,
519
+ port : port2 ,
520
+ host : '0.0.0.0' ,
521
+ client : {
522
+ webSocketURL : {
523
+ port : 0 ,
524
+ } ,
525
+ } ,
526
+ } ;
527
+
528
+ testServer . startAwaitingCompilation ( config , options , done ) ;
529
+ } ) ;
530
+
531
+ afterAll ( testServer . close ) ;
532
+
533
+ describe ( 'browser client' , ( ) => {
534
+ it ( 'should work' , ( done ) => {
535
+ runBrowser ( ) . then ( ( { page, browser } ) => {
536
+ waitForTest ( browser , page , / w s / , ( websocketUrl ) => {
537
+ expect ( websocketUrl ) . toContain (
538
+ `${ websocketUrlProtocol } ://localhost:${ port2 } /ws`
539
+ ) ;
540
+
541
+ done ( ) ;
542
+ } ) ;
543
+
544
+ page . goto ( `http://localhost:${ port2 } /main` ) ;
545
+ } ) ;
546
+ } ) ;
547
+ } ) ;
548
+ } ) ;
549
+
457
550
describe ( 'should work with "client.webSocketURL.port" and "client.webSocketURL.path" options' , ( ) => {
458
551
beforeAll ( ( done ) => {
459
552
const options = {
0 commit comments