File tree Expand file tree Collapse file tree
packages/angular_devkit/build_angular/src/builders/ssr-dev-server/specs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,26 +99,29 @@ describe('Serve SSR Builder - Works', () => {
9999
100100 it ( 'rejects requests with a disallowed Host header' , async ( ) => {
101101 const run = await architect . scheduleTarget ( target , { port : 0 } ) ;
102- const output = await run . result ;
103- expect ( output . success ) . toBeTrue ( ) ;
104-
105- const statusCode = await new Promise < number | undefined > ( ( resolve , reject ) => {
106- const req = get (
107- {
108- hostname : 'localhost' ,
109- port : output . port ,
110- path : '/' ,
111- headers : { host : 'example.com' } ,
112- } ,
113- ( res ) => {
114- res . resume ( ) ;
115- resolve ( res . statusCode ) ;
116- } ,
117- ) ;
118- req . on ( 'error' , reject ) ;
119- } ) ;
120-
121- await run . stop ( ) ;
122- expect ( statusCode ) . toBe ( 500 ) ;
102+ try {
103+ const output = await run . result ;
104+ expect ( output . success ) . toBeTrue ( ) ;
105+
106+ const statusCode = await new Promise < number | undefined > ( ( resolve , reject ) => {
107+ const req = get (
108+ {
109+ hostname : 'localhost' ,
110+ port : output . port ,
111+ path : '/' ,
112+ headers : { host : 'example.com' } ,
113+ } ,
114+ ( res ) => {
115+ res . resume ( ) ;
116+ resolve ( res . statusCode ) ;
117+ } ,
118+ ) ;
119+ req . on ( 'error' , reject ) ;
120+ } ) ;
121+
122+ expect ( statusCode ) . toBe ( 500 ) ;
123+ } finally {
124+ await run . stop ( ) ;
125+ }
123126 } ) ;
124127} ) ;
You can’t perform that action at this time.
0 commit comments