File tree 2 files changed +26
-2
lines changed
packages/angular_devkit/build_angular
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -216,10 +216,9 @@ export function serveWebpackBrowser(
216
216
217
217
if ( first ) {
218
218
first = false ;
219
-
220
219
context . logger . info ( tags . oneLine `
221
220
**
222
- Angular Live Development Server is listening on ${ options . host } :${ options . port } ,
221
+ Angular Live Development Server is listening on ${ options . host } :${ buildEvent . port } ,
223
222
open your browser on ${ serverAddress }
224
223
**
225
224
` ) ;
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