@@ -1532,12 +1532,13 @@ describe('web socket server URL', () => {
1532
1532
} ) ;
1533
1533
} ) ;
1534
1534
1535
- it ( `should work when "port" option is "auto" ("${ webSocketServer } ")` , async ( ) => {
1535
+ it ( `should work when "host" option is IPv4 ("${ webSocketServer } ")` , async ( ) => {
1536
+ const hostname = internalIp . v4 . sync ( ) ;
1536
1537
const compiler = webpack ( config ) ;
1537
1538
const devServerOptions = {
1538
1539
webSocketServer,
1539
- port : 'auto' ,
1540
- host : '0.0.0.0' ,
1540
+ port : port1 ,
1541
+ host : hostname ,
1541
1542
} ;
1542
1543
const server = new Server ( devServerOptions , compiler ) ;
1543
1544
@@ -1553,8 +1554,6 @@ describe('web socket server URL', () => {
1553
1554
} ) ;
1554
1555
} ) ;
1555
1556
1556
- const resolvedFreePort = server . options . port ;
1557
-
1558
1557
const { page, browser } = await runBrowser ( ) ;
1559
1558
1560
1559
const pageErrors = [ ] ;
@@ -1573,8 +1572,8 @@ describe('web socket server URL', () => {
1573
1572
if ( webSocketServer === 'ws' ) {
1574
1573
const client = page . _client ;
1575
1574
1576
- client . on ( 'Network.webSocketCreated' , ( request ) => {
1577
- webSocketRequests . push ( request ) ;
1575
+ client . on ( 'Network.webSocketCreated' , ( test ) => {
1576
+ webSocketRequests . push ( test ) ;
1578
1577
} ) ;
1579
1578
} else {
1580
1579
page . on ( 'request' , ( request ) => {
@@ -1584,14 +1583,14 @@ describe('web socket server URL', () => {
1584
1583
} ) ;
1585
1584
}
1586
1585
1587
- await page . goto ( `http://127.0.0.1 :${ resolvedFreePort } /main` , {
1586
+ await page . goto ( `http://${ hostname } :${ port1 } /main` , {
1588
1587
waitUntil : 'networkidle0' ,
1589
1588
} ) ;
1590
1589
1591
1590
const webSocketRequest = webSocketRequests [ 0 ] ;
1592
1591
1593
1592
expect ( webSocketRequest . url ) . toContain (
1594
- `${ websocketURLProtocol } ://127.0.0.1 :${ resolvedFreePort } /ws`
1593
+ `${ websocketURLProtocol } ://${ hostname } :${ port1 } /ws`
1595
1594
) ;
1596
1595
expect ( consoleMessages . map ( ( message ) => message . text ( ) ) ) . toMatchSnapshot (
1597
1596
'console messages'
@@ -1612,13 +1611,13 @@ describe('web socket server URL', () => {
1612
1611
} ) ;
1613
1612
} ) ;
1614
1613
1615
- it ( `should work when "host" option is IPv4 ("${ webSocketServer } ")` , async ( ) => {
1614
+ it ( `should work when "host" option is "local-ip" ("${ webSocketServer } ")` , async ( ) => {
1616
1615
const hostname = internalIp . v4 . sync ( ) ;
1617
1616
const compiler = webpack ( config ) ;
1618
1617
const devServerOptions = {
1619
1618
webSocketServer,
1620
1619
port : port1 ,
1621
- host : hostname ,
1620
+ host : 'local-ip' ,
1622
1621
} ;
1623
1622
const server = new Server ( devServerOptions , compiler ) ;
1624
1623
@@ -1691,13 +1690,13 @@ describe('web socket server URL', () => {
1691
1690
} ) ;
1692
1691
} ) ;
1693
1692
1694
- it ( `should work when "host" option is "local-ip " ("${ webSocketServer } ")` , async ( ) => {
1693
+ it ( `should work when "host" option is "local-ipv4 " ("${ webSocketServer } ")` , async ( ) => {
1695
1694
const hostname = internalIp . v4 . sync ( ) ;
1696
1695
const compiler = webpack ( config ) ;
1697
1696
const devServerOptions = {
1698
1697
webSocketServer,
1699
1698
port : port1 ,
1700
- host : 'local-ip ' ,
1699
+ host : 'local-ipv4 ' ,
1701
1700
} ;
1702
1701
const server = new Server ( devServerOptions , compiler ) ;
1703
1702
@@ -1770,13 +1769,12 @@ describe('web socket server URL', () => {
1770
1769
} ) ;
1771
1770
} ) ;
1772
1771
1773
- it ( `should work when "host" option is "local-ipv4" ("${ webSocketServer } ")` , async ( ) => {
1774
- const hostname = internalIp . v4 . sync ( ) ;
1772
+ it ( `should work when "port" option is "auto" ("${ webSocketServer } ")` , async ( ) => {
1775
1773
const compiler = webpack ( config ) ;
1776
1774
const devServerOptions = {
1777
1775
webSocketServer,
1778
- port : port1 ,
1779
- host : 'local-ipv4 ' ,
1776
+ port : 'auto' ,
1777
+ host : '0.0.0.0 ' ,
1780
1778
} ;
1781
1779
const server = new Server ( devServerOptions , compiler ) ;
1782
1780
@@ -1792,6 +1790,8 @@ describe('web socket server URL', () => {
1792
1790
} ) ;
1793
1791
} ) ;
1794
1792
1793
+ const resolvedFreePort = server . options . port ;
1794
+
1795
1795
const { page, browser } = await runBrowser ( ) ;
1796
1796
1797
1797
const pageErrors = [ ] ;
@@ -1810,8 +1810,8 @@ describe('web socket server URL', () => {
1810
1810
if ( webSocketServer === 'ws' ) {
1811
1811
const client = page . _client ;
1812
1812
1813
- client . on ( 'Network.webSocketCreated' , ( test ) => {
1814
- webSocketRequests . push ( test ) ;
1813
+ client . on ( 'Network.webSocketCreated' , ( request ) => {
1814
+ webSocketRequests . push ( request ) ;
1815
1815
} ) ;
1816
1816
} else {
1817
1817
page . on ( 'request' , ( request ) => {
@@ -1821,14 +1821,14 @@ describe('web socket server URL', () => {
1821
1821
} ) ;
1822
1822
}
1823
1823
1824
- await page . goto ( `http://${ hostname } :${ port1 } /main` , {
1824
+ await page . goto ( `http://127.0.0.1 :${ resolvedFreePort } /main` , {
1825
1825
waitUntil : 'networkidle0' ,
1826
1826
} ) ;
1827
1827
1828
1828
const webSocketRequest = webSocketRequests [ 0 ] ;
1829
1829
1830
1830
expect ( webSocketRequest . url ) . toContain (
1831
- `${ websocketURLProtocol } ://${ hostname } :${ port1 } /ws`
1831
+ `${ websocketURLProtocol } ://127.0.0.1 :${ resolvedFreePort } /ws`
1832
1832
) ;
1833
1833
expect ( consoleMessages . map ( ( message ) => message . text ( ) ) ) . toMatchSnapshot (
1834
1834
'console messages'
0 commit comments