@@ -60,9 +60,10 @@ describe('test/app_worker.test.ts', () => {
6060 } ) ;
6161
6262 return app
63- // .debug()
63+ . debug ( )
6464 . expect ( 'code' , 1 )
65- . expect ( 'stderr' , / C u s t o m E r r o r : m o c k e r r o r \[ h t t p s \: \/ \/ e g g j s \. o r g \/ z h - c n \/ f a q \/ c u s t o m P l u g i n _ 9 9 \] / )
65+ . expect ( 'stderr' , / C u s t o m E r r o r : m o c k e r r o r / )
66+ // .expect('stderr', /CustomError: mock error \[ https\:\/\/eggjs\.org\/zh-cn\/faq\/customPlugin_99 \]/)
6667 . end ( ) ;
6768 } ) ;
6869
@@ -78,7 +79,8 @@ describe('test/app_worker.test.ts', () => {
7879 return app
7980 // .debug()
8081 . expect ( 'code' , 1 )
81- . expect ( 'stderr' , / C u s t o m E r r o r : m o c k e r r o r \[ h t t p s \: \/ \/ e g g j s \. o r g \/ z h - c n \/ f a q \/ c u s t o m P l u g i n _ 9 9 \] / )
82+ . expect ( 'stderr' , / C u s t o m E r r o r : m o c k e r r o r / )
83+ // .expect('stderr', /CustomError: mock error \[ https\:\/\/eggjs\.org\/zh-cn\/faq\/customPlugin_99 \]/)
8284 . end ( ) ;
8385 } ) ;
8486
@@ -116,7 +118,7 @@ describe('test/app_worker.test.ts', () => {
116118 . expect ( 200 ) ;
117119
118120 // wait app worker restart
119- await scheduler . wait ( 10000 ) ;
121+ await scheduler . wait ( 5000 ) ;
120122
121123 app . expect ( 'stdout' , / a p p _ w o r k e r # 1 : \d + d i s c o n n e c t / ) ;
122124 app . expect ( 'stdout' , / a p p _ w o r k e r # 2 : \d + s t a r t e d / ) ;
@@ -130,21 +132,23 @@ describe('test/app_worker.test.ts', () => {
130132 // app.debug();
131133 return app . ready ( ) ;
132134 } ) ;
133- after ( mm . restore ) ;
135+ after ( async ( ) => {
136+ await app . close ( ) ;
137+ await mm . restore ( ) ;
138+ } ) ;
134139
135- it ( 'should restart' , async ( ) => {
140+ it ( 'should restart disable on local env ' , async ( ) => {
136141 try {
137142 await app . httpRequest ( )
138143 . get ( '/exit' ) ;
139144 } catch ( _ ) {
140145 // ignore
141146 }
142147
143- // wait app worker restart
144- await scheduler . wait ( 10000 ) ;
148+ await scheduler . wait ( 1000 ) ;
145149
146- app . expect ( 'stdout ' , / a p p _ w o r k e r # 1 : \d + d i s c o n n e c t / ) ;
147- app . expect ( 'stderr' , / d o n ' t f o r k n e w w o r k / ) ;
150+ app . expect ( 'stderr ' , / w o r k e r : \d + d i s c o n n e c t / ) ;
151+ app . expect ( 'stderr' , / d o n ' t f o r k n e w w o r k \( r e f o r k : f a l s e , r e f o r k C o u n t : 0 \) / ) ;
148152 } ) ;
149153 } ) ;
150154
@@ -166,9 +170,9 @@ describe('test/app_worker.test.ts', () => {
166170 }
167171
168172 // wait app worker restart
169- await scheduler . wait ( 10000 ) ;
173+ await scheduler . wait ( 1000 ) ;
170174
171- app . expect ( 'stdout ' , / a p p _ w o r k e r # 1 : \d + d i s c o n n e c t / ) ;
175+ app . expect ( 'stderr ' , / w o r k e r : \d + d i s c o n n e c t / ) ;
172176 app . expect ( 'stderr' , / d o n ' t f o r k n e w w o r k / ) ;
173177 } ) ;
174178 } ) ;
@@ -192,20 +196,24 @@ describe('test/app_worker.test.ts', () => {
192196 beforeEach ( ( ) => {
193197 mm . env ( 'default' ) ;
194198 } ) ;
195- afterEach ( mm . restore ) ;
199+ afterEach ( async ( ) => {
200+ await app . close ( ) ;
201+ await mm . restore ( ) ;
202+ } ) ;
196203 afterEach ( ( ) => rm ( sockFile , { force : true , recursive : true } ) ) ;
197204
198- it ( 'should error then port is not specified ' , async ( ) => {
205+ it ( 'should set default port 170xx then config.listen. port is null ' , async ( ) => {
199206 app = cluster ( 'apps/app-listen-without-port' ) ;
200207 // app.debug();
201208 await app . ready ( ) ;
202209
203- app . expect ( 'code' , 1 ) ;
204- app . expect ( 'stderr' , / p o r t s h o u l d b e n u m b e r , b u t g o t n u l l / ) ;
210+ app . expect ( 'code' , 0 ) ;
211+ app . expect ( 'stdout' , / e g g s t a r t e d o n h t t p : \/ \/ 1 2 7 .0 .0 .1 : \d + / ) ;
212+ // app.expect('stderr', /port should be number, but got null/);
205213 } ) ;
206214
207215 it ( 'should use port in config' , async ( ) => {
208- app = cluster ( 'apps/app-listen-port' ) ;
216+ app = cluster ( 'apps/app-listen-port' , { port : 0 } ) ;
209217 // app.debug();
210218 await app . ready ( ) ;
211219
@@ -231,12 +239,22 @@ describe('test/app_worker.test.ts', () => {
231239 . get ( '/port' )
232240 . expect ( '17010' )
233241 . expect ( 200 ) ;
242+
243+ // ipv6
244+ // await request('http://[::1]:17010')
245+ // .get('/')
246+ // .expect('done')
247+ // .expect(200);
248+ // await request('http://[::1]:17010')
249+ // .get('/port')
250+ // .expect('17010')
251+ // .expect(200);
234252 } ) ;
235253
236254 it ( 'should use hostname in config' , async ( ) => {
237255 const url = ip ( ) + ':17010' ;
238256
239- app = cluster ( 'apps/app-listen-hostname' ) ;
257+ app = cluster ( 'apps/app-listen-hostname' , { port : 0 } ) ;
240258 // app.debug();
241259 await app . ready ( ) ;
242260
0 commit comments