@@ -7,20 +7,20 @@ const helper = require('./helper');
7
7
const config = require ( './fixtures/client-config/webpack.config' ) ;
8
8
const runBrowser = require ( './helpers/run-browser' ) ;
9
9
10
- function startProxy ( port ) {
11
- const proxy = express ( ) ;
12
- proxy . use (
13
- '/' ,
14
- httpProxy ( {
15
- target : 'http://localhost:9001' ,
16
- ws : true ,
17
- changeOrigin : true ,
18
- } )
19
- ) ;
20
- return proxy . listen ( port ) ;
21
- }
22
-
23
10
describe ( 'Client code' , ( ) => {
11
+ function startProxy ( port ) {
12
+ const proxy = express ( ) ;
13
+ proxy . use (
14
+ '/' ,
15
+ httpProxy ( {
16
+ target : 'http://localhost:9001' ,
17
+ ws : true ,
18
+ changeOrigin : true ,
19
+ } )
20
+ ) ;
21
+ return proxy . listen ( port ) ;
22
+ }
23
+
24
24
beforeAll ( ( done ) => {
25
25
const options = {
26
26
compress : true ,
@@ -38,6 +38,7 @@ describe('Client code', () => {
38
38
39
39
afterAll ( helper . close ) ;
40
40
41
+ // [HPM] Proxy created: / -> http://localhost:9001
41
42
describe ( 'behind a proxy' , ( ) => {
42
43
let proxy ;
43
44
@@ -47,13 +48,21 @@ describe('Client code', () => {
47
48
proxy = startProxy ( 9000 ) ;
48
49
} ) ;
49
50
50
- afterAll ( ( ) => {
51
- proxy . close ( ) ;
51
+ afterAll ( ( done ) => {
52
+ proxy . close ( ( ) => {
53
+ done ( ) ;
54
+ } ) ;
52
55
} ) ;
53
56
54
57
it ( 'responds with a 200' , ( done ) => {
55
- const req = request ( 'http://localhost:9000' ) ;
56
- req . get ( '/sockjs-node' ) . expect ( 200 , 'Welcome to SockJS!\n' , done ) ;
58
+ {
59
+ const req = request ( 'http://localhost:9000' ) ;
60
+ req . get ( '/sockjs-node' ) . expect ( 200 , 'Welcome to SockJS!\n' , done ) ;
61
+ }
62
+ {
63
+ const req = request ( 'http://localhost:9001' ) ;
64
+ req . get ( '/sockjs-node' ) . expect ( 200 , 'Welcome to SockJS!\n' , done ) ;
65
+ }
57
66
} ) ;
58
67
59
68
it ( 'requests websocket through the proxy with proper port number' , ( done ) => {
@@ -62,7 +71,7 @@ describe('Client code', () => {
62
71
. waitForRequest ( ( requestObj ) => requestObj . url ( ) . match ( / s o c k j s - n o d e / ) )
63
72
. then ( ( requestObj ) => {
64
73
expect ( requestObj . url ( ) ) . toMatch (
65
- / ^ h t t p : \/ \/ l o c a l h o s t : 9 0 0 0 \/ s o c k j s - n o d e /
74
+ / ^ h t t p : \/ \/ l o c a l h o s t : 9 0 0 1 \/ s o c k j s - n o d e /
66
75
) ;
67
76
browser . close ( ) . then ( done ) ;
68
77
} ) ;
0 commit comments