File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
packages/angular_devkit/build_angular Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -216,10 +216,9 @@ export function serveWebpackBrowser(
216216
217217 if ( first ) {
218218 first = false ;
219-
220219 context . logger . info ( tags . oneLine `
221220 **
222- Angular Live Development Server is listening on ${ options . host } :${ options . port } ,
221+ Angular Live Development Server is listening on ${ options . host } :${ buildEvent . port } ,
223222 open your browser on ${ serverAddress }
224223 **
225224 ` ) ;
Original file line number Diff line number Diff line change @@ -67,4 +67,29 @@ describe('Dev Server Builder', () => {
6767 expect ( res ) . not . toContain ( 'This file is automatically generated during release.' ) ;
6868 expect ( res ) . toContain ( '<title>HelloWorldApp</title>' ) ;
6969 } ) ;
70+
71+ it ( 'works with port 0' , async ( ) => {
72+ const logger = new logging . Logger ( '' ) ;
73+ const logs : string [ ] = [ ] ;
74+ logger . subscribe ( e => logs . push ( e . message ) ) ;
75+
76+ const run = await architect . scheduleTarget ( target , { port : 0 } , { logger } ) ;
77+ runs . push ( run ) ;
78+ const output = await run . result as DevServerBuilderOutput ;
79+ expect ( output . success ) . toBe ( true ) ;
80+
81+ const groups = logs . join ( ) . match ( / \: ( \d + ) { 4 , 6 } / g) ;
82+ if ( ! groups ) {
83+ throw new Error ( 'Expected log to contain port number.' ) ;
84+ }
85+
86+ // tests that both the ports in the logs are the same.
87+ const [ firstPort , secondPort ] = groups ;
88+ expect ( firstPort ) . toBe ( secondPort ) ;
89+
90+ expect ( output . baseUrl ) . toBe ( `http://localhost${ firstPort } /` ) ;
91+ const response = await fetch ( `http://localhost${ firstPort } /index.html` ) ;
92+ expect ( await response . text ( ) ) . toContain ( '<title>HelloWorldApp</title>' ) ;
93+ } ) ;
94+
7095} ) ;
You can’t perform that action at this time.
0 commit comments