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 @@ -195,10 +195,9 @@ export function serveWebpackBrowser(
195
195
196
196
if ( first ) {
197
197
first = false ;
198
-
199
198
context . logger . info ( tags . oneLine `
200
199
**
201
- Angular Live Development Server is listening on ${ options . host } :${ options . port } ,
200
+ Angular Live Development Server is listening on ${ options . host } :${ buildEvent . port } ,
202
201
open your browser on ${ serverAddress }
203
202
**
204
203
` ) ;
Original file line number Diff line number Diff line change @@ -67,4 +67,29 @@ describe('Dev Server Builder', () => {
67
67
expect ( res ) . not . toContain ( 'This file is automatically generated during release.' ) ;
68
68
expect ( res ) . toContain ( '<title>HelloWorldApp</title>' ) ;
69
69
} ) ;
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
+
70
95
} ) ;
You can’t perform that action at this time.
0 commit comments