@@ -35,6 +35,12 @@ async function startServer(middlewares) {
3535 return { port, server }
3636}
3737
38+ const post = ( port , body ) =>
39+ fetch ( `http://localhost:${ port } ` , { method : 'POST' , body } ) . catch ( error => {
40+ // This error began appearing randomly and seems to be a dev dependency bug.
41+ if ( error . code !== 'EPIPE' ) throw error
42+ } )
43+
3844function checkUpload ( t , { stream, ...meta } ) {
3945 t . truthy (
4046 stream . constructor . name === 'FileStream' ,
@@ -76,7 +82,7 @@ test('Single file.', async t => {
7682 body . append ( 'map' , JSON . stringify ( { '1' : [ 'variables.file' ] } ) )
7783 body . append ( '1' , fs . createReadStream ( TEST_FILE_PATH ) )
7884
79- await fetch ( `http://localhost: ${ port } ` , { method : 'POST' , body } )
85+ await post ( port , body )
8086
8187 server . close ( )
8288} )
@@ -110,7 +116,7 @@ test('Deduped files.', async t => {
110116
111117 body . append ( '1' , fs . createReadStream ( TEST_FILE_PATH ) )
112118
113- await fetch ( `http://localhost: ${ port } ` , { method : 'POST' , body } )
119+ await post ( port , body )
114120
115121 server . close ( )
116122} )
@@ -140,7 +146,7 @@ test('Missing file.', async t => {
140146
141147 body . append ( 'map' , JSON . stringify ( { '1' : [ 'variables.file' ] } ) )
142148
143- await fetch ( `http://localhost: ${ port } ` , { method : 'POST' , body } )
149+ await post ( port , body )
144150
145151 server . close ( )
146152} )
@@ -170,7 +176,7 @@ test('Extraneous file.', async t => {
170176 body . append ( '1' , fs . createReadStream ( TEST_FILE_PATH ) )
171177 body . append ( '2' , fs . createReadStream ( TEST_FILE_PATH ) )
172178
173- await fetch ( `http://localhost: ${ port } ` , { method : 'POST' , body } )
179+ await post ( port , body )
174180
175181 server . close ( )
176182} )
@@ -206,7 +212,7 @@ test('Exceed max files.', async t => {
206212 body . append ( '1' , fs . createReadStream ( TEST_FILE_PATH ) )
207213 body . append ( '2' , fs . createReadStream ( TEST_FILE_PATH ) )
208214
209- await fetch ( `http://localhost: ${ port } ` , { method : 'POST' , body } )
215+ await post ( port , body )
210216
211217 server . close ( )
212218} )
@@ -250,7 +256,7 @@ test('Exceed max files with extraneous files intersperced.', async t => {
250256 body . append ( 'extraneous' , fs . createReadStream ( TEST_FILE_PATH ) )
251257 body . append ( '2' , fs . createReadStream ( TEST_FILE_PATH ) )
252258
253- await fetch ( `http://localhost: ${ port } ` , { method : 'POST' , body } )
259+ await post ( port , body )
254260
255261 server . close ( )
256262} )
@@ -294,7 +300,7 @@ test.failing.skip('Exceed max file size.', async t => {
294300
295301 body . append ( '1' , fs . createReadStream ( TEST_FILE_PATH ) )
296302
297- await fetch ( `http://localhost: ${ port } ` , { method : 'POST' , body } )
303+ await post ( port , body )
298304
299305 server . close ( )
300306} )
@@ -328,7 +334,7 @@ test('Misorder “map” before “operations”.', async t => {
328334
329335 body . append ( '1' , fs . createReadStream ( TEST_FILE_PATH ) )
330336
331- await fetch ( `http://localhost: ${ port } ` , { method : 'POST' , body } )
337+ await post ( port , body )
332338
333339 server . close ( )
334340} )
@@ -362,7 +368,7 @@ test('Misorder files before “map”.', async t => {
362368 } )
363369 )
364370
365- await fetch ( `http://localhost: ${ port } ` , { method : 'POST' , body } )
371+ await post ( port , body )
366372
367373 server . close ( )
368374} )
0 commit comments