diff --git a/test/unit/build-request-file-object.test.js b/test/unit/build-request-file-object.test.js index 1929e6fde..1aa14f3cc 100644 --- a/test/unit/build-request-file-object.test.js +++ b/test/unit/build-request-file-object.test.js @@ -61,7 +61,8 @@ describe('buildRequestFileObject', () => { }); it('should handle file object with a readable stream as its `value`', async () => { - const fileStream = fs.createReadStream(filepath); + // Note add an on error handler to avoid unhandled error events + const fileStream = fs.createReadStream(filepath).on('error', () => {}); fileStream.path = `/fake/path/${customName}`; const fileParams = { @@ -76,7 +77,8 @@ describe('buildRequestFileObject', () => { }); it('should handle path property being a buffer', async () => { - const fileStream = fs.createReadStream(filepath); + // Note add an on error handler to avoid unhandled error events + const fileStream = fs.createReadStream(filepath).on('error', () => {}); fileStream.path = Buffer.from(`/fake/path/${customName}`); const fileParams = { diff --git a/test/unit/get-content-type.test.js b/test/unit/get-content-type.test.js index 75610a451..aed976afa 100644 --- a/test/unit/get-content-type.test.js +++ b/test/unit/get-content-type.test.js @@ -26,7 +26,8 @@ describe('getContentType', () => { }); it('should not get content type from read stream with corrupted path property', async () => { - const streamFile = fs.createReadStream(filepath); + // Note add an on error handler to avoid unhandled error events + const streamFile = fs.createReadStream(filepath).on('error', () => {}); streamFile.path = 'unrecognizeable-format'; expect(await getContentType(streamFile)).toBeNull(); });