File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ async function expectInStream(
4848) : Promise < void > {
4949 let content = '' ;
5050 let ended = false ;
51- await Promise . race ( [
51+ const result = await Promise . race ( [
5252 ( async ( ) => {
5353 for await ( const chunk of stream ) {
5454 content += chunk ;
@@ -57,17 +57,15 @@ async function expectInStream(
5757 }
5858 }
5959 ended = true ;
60+ return 'normal-completion' as const ;
6061 } ) ( ) ,
61- ...( timeoutMs
62- ? [
63- delay ( timeoutMs ) . then ( ( ) => {
64- throw new Error (
65- `Timeout waiting for substring: ${ substring } , found so far: ${ content } (ended = ${ ended } )`
66- ) ;
67- } ) ,
68- ]
69- : [ ] ) ,
62+ ...( timeoutMs ? [ delay ( timeoutMs ) . then ( ( ) => 'timeout' as const ) ] : [ ] ) ,
7063 ] ) ;
64+ if ( result === 'timeout' ) {
65+ throw new Error (
66+ `Timeout waiting for substring: ${ substring } , found so far: ${ content } (ended = ${ ended } )`
67+ ) ;
68+ }
7169 expect ( content ) . to . include ( substring ) ;
7270}
7371
You can’t perform that action at this time.
0 commit comments