@@ -28,6 +28,7 @@ describe('ConcurrentOutput', () => {
2828 // Given
2929 const backendSync = new Synchronizer ( )
3030 const frontendSync = new Synchronizer ( )
31+ const gate = new Synchronizer ( )
3132
3233 const backendProcess = {
3334 prefix : 'backend' ,
@@ -37,6 +38,7 @@ describe('ConcurrentOutput', () => {
3738 stdout . write ( 'third backend message' )
3839
3940 backendSync . resolve ( )
41+ await gate . promise
4042 } ,
4143 }
4244
@@ -50,6 +52,7 @@ describe('ConcurrentOutput', () => {
5052 stdout . write ( 'third frontend message' )
5153
5254 frontendSync . resolve ( )
55+ await gate . promise
5356 } ,
5457 }
5558 // When
@@ -72,19 +75,23 @@ describe('ConcurrentOutput', () => {
7275 00:00:00 │ frontend │ third frontend message
7376 "
7477 ` )
78+
79+ gate . resolve ( )
7580 } )
7681
7782 test ( 'strips ansi codes from the output by default' , async ( ) => {
7883 const output = 'foo'
7984
8085 // Given
8186 const processSync = new Synchronizer ( )
87+ const gate = new Synchronizer ( )
8288 const processes = [
8389 {
8490 prefix : '1' ,
8591 action : async ( stdout : Writable , _stderr : Writable , _signal : AbortSignal ) => {
8692 stdout . write ( `\u001b[32m${ output } \u001b[39m` )
8793 processSync . resolve ( )
94+ await gate . promise
8895 } ,
8996 } ,
9097 ]
@@ -98,13 +105,15 @@ describe('ConcurrentOutput', () => {
98105 const logColumns = renderInstance . lastFrame ( ) ! . split ( '│' )
99106 expect ( logColumns . length ) . toBe ( 3 )
100107 expect ( logColumns [ 2 ] ?. trim ( ) ) . toEqual ( output )
108+ gate . resolve ( )
101109 } )
102110
103111 test ( 'does not strip ansi codes from the output when stripAnsi is false' , async ( ) => {
104112 const output = '\u001b[32mfoo\u001b[39m'
105113
106114 // Given
107115 const processSync = new Synchronizer ( )
116+ const gate = new Synchronizer ( )
108117 const processes = [
109118 {
110119 prefix : '1' ,
@@ -113,6 +122,7 @@ describe('ConcurrentOutput', () => {
113122 stdout . write ( output )
114123 } )
115124 processSync . resolve ( )
125+ await gate . promise
116126 } ,
117127 } ,
118128 ]
@@ -126,11 +136,13 @@ describe('ConcurrentOutput', () => {
126136 const logColumns = renderInstance . lastFrame ( ) ! . split ( '│' )
127137 expect ( logColumns . length ) . toBe ( 3 )
128138 expect ( logColumns [ 2 ] ?. trim ( ) ) . toEqual ( output )
139+ gate . resolve ( )
129140 } )
130141
131142 test ( 'renders custom prefixes on log lines' , async ( ) => {
132143 // Given
133144 const processSync = new Synchronizer ( )
145+ const gate = new Synchronizer ( )
134146 const extensionName = 'my-extension'
135147 const processes = [
136148 {
@@ -140,6 +152,7 @@ describe('ConcurrentOutput', () => {
140152 stdout . write ( 'foo bar' )
141153 } )
142154 processSync . resolve ( )
155+ await gate . promise
143156 } ,
144157 } ,
145158 ]
@@ -161,12 +174,14 @@ describe('ConcurrentOutput', () => {
161174 const logColumns = unstyled ( renderInstance . lastFrame ( ) ! ) . split ( '│' )
162175 expect ( logColumns . length ) . toBe ( 3 )
163176 expect ( logColumns [ 1 ] ?. trim ( ) ) . toEqual ( extensionName )
177+ gate . resolve ( )
164178 } )
165179
166180 test ( 'renders prefix column width based on prefixColumnSize' , async ( ) => {
167181 // Given
168182 const processSync1 = new Synchronizer ( )
169183 const processSync2 = new Synchronizer ( )
184+ const gate = new Synchronizer ( )
170185
171186 const columnSize = 5
172187 const processes = [
@@ -175,13 +190,15 @@ describe('ConcurrentOutput', () => {
175190 action : async ( stdout : Writable , _stderr : Writable , _signal : AbortSignal ) => {
176191 stdout . write ( 'foo' )
177192 processSync1 . resolve ( )
193+ await gate . promise
178194 } ,
179195 } ,
180196 {
181197 prefix : '1' ,
182198 action : async ( stdout : Writable , _stderr : Writable , _signal : AbortSignal ) => {
183199 stdout . write ( 'bar' )
184200 processSync2 . resolve ( )
201+ await gate . promise
185202 } ,
186203 } ,
187204 ]
@@ -206,22 +223,25 @@ describe('ConcurrentOutput', () => {
206223 // Including spacing
207224 expect ( logColumns [ 1 ] ?. length ) . toBe ( columnSize + 2 )
208225 } )
226+ gate . resolve ( )
209227 } )
210228
211229 test ( 'renders prefix column width based on processes by default' , async ( ) => {
212230 // Given
213231 const processSync = new Synchronizer ( )
232+ const gate = new Synchronizer ( )
214233 const processes = [
215234 {
216235 prefix : '1' ,
217236 action : async ( stdout : Writable , _stderr : Writable , _signal : AbortSignal ) => {
218237 stdout . write ( 'foo' )
219238 processSync . resolve ( )
239+ await gate . promise
220240 } ,
221241 } ,
222- { prefix : '12' , action : async ( ) => { } } ,
223- { prefix : '123' , action : async ( ) => { } } ,
224- { prefix : '1234' , action : async ( ) => { } } ,
242+ { prefix : '12' , action : async ( ) => gate . promise } ,
243+ { prefix : '123' , action : async ( ) => gate . promise } ,
244+ { prefix : '1234' , action : async ( ) => gate . promise } ,
225245 ]
226246
227247 // When
@@ -234,20 +254,23 @@ describe('ConcurrentOutput', () => {
234254 expect ( logColumns . length ) . toBe ( 3 )
235255 // 4 is largest prefix, plus spacing
236256 expect ( logColumns [ 1 ] ?. length ) . toBe ( 4 + 2 )
257+ gate . resolve ( )
237258 } )
238259
239260 test ( 'does not render prefix column larger than max' , async ( ) => {
240261 // Given
241262 const processSync = new Synchronizer ( )
263+ const gate = new Synchronizer ( )
242264 const processes = [
243265 {
244266 prefix : '1' ,
245267 action : async ( stdout : Writable , _stderr : Writable , _signal : AbortSignal ) => {
246268 stdout . write ( 'foo' )
247269 processSync . resolve ( )
270+ await gate . promise
248271 } ,
249272 } ,
250- { prefix : new Array ( 26 ) . join ( '0' ) , action : async ( ) => { } } ,
273+ { prefix : new Array ( 26 ) . join ( '0' ) , action : async ( ) => gate . promise } ,
251274 ]
252275
253276 // When
@@ -260,6 +283,7 @@ describe('ConcurrentOutput', () => {
260283 expect ( logColumns . length ) . toBe ( 3 )
261284 // 25 is largest column allowed, plus spacing
262285 expect ( logColumns [ 1 ] ?. length ) . toBe ( 25 + 2 )
286+ gate . resolve ( )
263287 } )
264288
265289 test ( 'rejects with the error thrown inside one of the processes' , async ( ) => {
0 commit comments