@@ -618,7 +618,7 @@ describe("proxy option", () => {
618618
619619 const BACKEND_MESSAGE_TYPE = "backend-message" ;
620620
621- beforeAll ( async ( ) => {
621+ before ( async ( ) => {
622622 backendUpgradeCount = 0 ;
623623
624624 backend = http . createServer ( ) ;
@@ -654,7 +654,7 @@ describe("proxy option", () => {
654654 await server . start ( ) ;
655655 } ) ;
656656
657- afterAll ( async ( ) => {
657+ after ( async ( ) => {
658658 for ( const client of backendWss . clients ) {
659659 client . terminate ( ) ;
660660 }
@@ -716,10 +716,8 @@ describe("proxy option", () => {
716716 let backend ;
717717 let stderrSpy ;
718718
719- beforeAll ( async ( ) => {
720- stderrSpy = jest
721- . spyOn ( process . stderr , "write" )
722- . mockImplementation ( ( ) => true ) ;
719+ before ( async ( ) => {
720+ stderrSpy = spyOn ( process . stderr , "write" ) . mockImplementation ( ( ) => true ) ;
723721
724722 backend = http . createServer ( ) ;
725723 backend . on ( "upgrade" , ( req , socket ) => {
@@ -751,7 +749,7 @@ describe("proxy option", () => {
751749 await server . start ( ) ;
752750 } ) ;
753751
754- afterAll ( async ( ) => {
752+ after ( async ( ) => {
755753 stderrSpy . mockRestore ( ) ;
756754 backend . closeAllConnections ( ) ;
757755 await server . stop ( ) ;
@@ -897,22 +895,16 @@ describe("proxy option", () => {
897895
898896 // Behavior shared by every WebSocket server implementation: the HMR socket
899897 // is served locally and never forwarded, while any path the HMR server does
900- // not own falls through to the user proxy. SockJS serves its transport under
901- // `/<prefix>/<server>/<session>/websocket`, not the bare `/ws`.
898+ // not own falls through to the user proxy.
902899 const serverTypes = [
903900 { type : "ws" , hmrPath : "/ws" , nonHmrPath : "/not-hmr" } ,
904- {
905- type : "sockjs" ,
906- hmrPath : "/ws/000/abcd1234/websocket" ,
907- nonHmrPath : "/not-hmr" ,
908- } ,
909901 ] ;
910902
911903 for ( const { type, hmrPath, nonHmrPath } of serverTypes ) {
912904 describe ( `with webSocketServerType: ${ type } ` , ( ) => {
913- beforeAll ( ( ) => setup ( { webSocketServer : type } ) ) ;
905+ before ( ( ) => setup ( { webSocketServer : type } ) ) ;
914906
915- afterAll ( teardown ) ;
907+ after ( teardown ) ;
916908
917909 it ( "serves the HMR upgrade locally and does not forward it to the proxy" , async ( ) => {
918910 const { opened, forwarded } = await probe ( hmrPath ) ;
@@ -933,42 +925,46 @@ describe("proxy option", () => {
933925 // `WebSocketServer#shouldHandle` does, so only the configured path (query
934926 // stripped) is the HMR socket; every other variant is forwarded.
935927 describe ( "with the `ws` server, path matching is exact" , ( ) => {
936- beforeAll ( ( ) => setup ( { webSocketServer : "ws" } ) ) ;
928+ before ( ( ) => setup ( { webSocketServer : "ws" } ) ) ;
937929
938- afterAll ( teardown ) ;
930+ after ( teardown ) ;
939931
940- it . each ( [
932+ for ( const [ label , path ] of [
941933 [ "exact path" , "/ws" ] ,
942934 [ "path with query string" , "/ws?token=1" ] ,
943- ] ) ( "treats %s (%s) as the HMR upgrade path" , async ( _label , path ) => {
944- const { forwarded } = await probe ( path ) ;
935+ ] ) {
936+ it ( `treats ${ label } (${ path } ) as the HMR upgrade path` , async ( ) => {
937+ const { forwarded } = await probe ( path ) ;
945938
946- expect ( forwarded ) . toBe ( false ) ;
947- } ) ;
939+ expect ( forwarded ) . toBe ( false ) ;
940+ } ) ;
941+ }
948942
949- it . each ( [
943+ for ( const [ label , path ] of [
950944 [ "leading double slash" , "//ws" ] ,
951945 [ "trailing slash" , "/ws/" ] ,
952946 [ "uppercase" , "/WS" ] ,
953947 [ "mixed case" , "/wS" ] ,
954948 [ "percent-encoded path" , "/%77%73" ] ,
955- ] ) ( "forwards %s (%s) to the user proxy" , async ( _label , path ) => {
956- const { forwarded } = await probe ( path ) ;
949+ ] ) {
950+ it ( `forwards ${ label } (${ path } ) to the user proxy` , async ( ) => {
951+ const { forwarded } = await probe ( path ) ;
957952
958- expect ( forwarded ) . toBe ( true ) ;
959- } ) ;
953+ expect ( forwarded ) . toBe ( true ) ;
954+ } ) ;
955+ }
960956 } ) ;
961957
962958 // The HMR path is read from the configured `webSocketServer` options, not a
963959 // hardcoded `/ws`.
964960 describe ( "with a custom `ws` path" , ( ) => {
965- beforeAll ( ( ) =>
961+ before ( ( ) =>
966962 setup ( {
967963 webSocketServer : { type : "ws" , options : { path : "/custom-hmr" } } ,
968964 } ) ,
969965 ) ;
970966
971- afterAll ( teardown ) ;
967+ after ( teardown ) ;
972968
973969 it ( "treats the configured path (/custom-hmr) as the HMR upgrade path" , async ( ) => {
974970 const { forwarded } = await probe ( "/custom-hmr" ) ;
@@ -986,11 +982,11 @@ describe("proxy option", () => {
986982 // With no HMR server there is no socket to protect, so the filter never
987983 // engages and even `/ws` is forwarded to the user proxy.
988984 describe ( "without a webSocketServer" , ( ) => {
989- beforeAll ( ( ) =>
985+ before ( ( ) =>
990986 setup ( { hot : false , liveReload : false , webSocketServer : false } ) ,
991987 ) ;
992988
993- afterAll ( teardown ) ;
989+ after ( teardown ) ;
994990
995991 it ( "forwards /ws to the user proxy because there is no HMR socket to protect" , async ( ) => {
996992 const { forwarded } = await probe ( "/ws" ) ;
0 commit comments