@@ -42,7 +42,7 @@ describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupT
4242 port : undefined ,
4343 } ) ;
4444
45- const { result, response, logs } = await executeOnceAndFetch ( harness , '/' ) ;
45+ const { result, response } = await executeOnceAndFetch ( harness , '/' ) ;
4646
4747 expect ( result ?. success ) . toBeTrue ( ) ;
4848 expect ( getResultPort ( result ) ) . toBe ( '4200' ) ;
@@ -55,7 +55,7 @@ describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupT
5555 port : 0 ,
5656 } ) ;
5757
58- const { result, response, logs } = await executeOnceAndFetch ( harness , '/' ) ;
58+ const { result, response } = await executeOnceAndFetch ( harness , '/' ) ;
5959
6060 expect ( result ?. success ) . toBeTrue ( ) ;
6161 const port = getResultPort ( result ) ;
@@ -73,11 +73,30 @@ describeServeBuilder(executeDevServer, DEV_SERVER_BUILDER_INFO, (harness, setupT
7373 port : 8000 ,
7474 } ) ;
7575
76- const { result, response, logs } = await executeOnceAndFetch ( harness , '/' ) ;
76+ const { result, response } = await executeOnceAndFetch ( harness , '/' ) ;
7777
7878 expect ( result ?. success ) . toBeTrue ( ) ;
7979 expect ( getResultPort ( result ) ) . toBe ( '8000' ) ;
8080 expect ( await response ?. text ( ) ) . toContain ( '<title>' ) ;
8181 } ) ;
82+
83+ it ( 'should be overwritten by process.env.PORT if it exists' , async ( ) => {
84+ harness . useTarget ( 'serve' , {
85+ ...BASE_OPTIONS ,
86+ port : 8000 ,
87+ } ) ;
88+
89+ process . env . PORT = '4201' ;
90+
91+ const { result, response } = await executeOnceAndFetch ( harness , '/' ) ;
92+
93+ expect ( result ?. success ) . toBeTrue ( ) ;
94+ expect ( getResultPort ( result ) ) . toBe ( '4201' ) ;
95+ expect ( await response ?. text ( ) ) . toContain ( '<title>' ) ;
96+
97+ expect ( 1 ) . toEqual ( 2 ) ;
98+
99+ delete process . env . PORT ;
100+ } ) ;
82101 } ) ;
83102} ) ;
0 commit comments