From 7df0f276bfa7b6440b806d3fe1089f73863b26d7 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 23 May 2022 18:46:33 +0200 Subject: [PATCH] No mocking with Jest and ESM --- __mocks__/nanoid/non-secure.js | 1 - packages/@uppy/core/src/Uppy.test.js | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) delete mode 100644 __mocks__/nanoid/non-secure.js diff --git a/__mocks__/nanoid/non-secure.js b/__mocks__/nanoid/non-secure.js deleted file mode 100644 index a5c69d9fdc..0000000000 --- a/__mocks__/nanoid/non-secure.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = { nanoid: () => 'cjd09qwxb000dlql4tp4doz8h' } diff --git a/packages/@uppy/core/src/Uppy.test.js b/packages/@uppy/core/src/Uppy.test.js index f1b582dbf9..01196a635b 100644 --- a/packages/@uppy/core/src/Uppy.test.js +++ b/packages/@uppy/core/src/Uppy.test.js @@ -896,7 +896,12 @@ describe('src/Core', () => { core.addFile({ source: 'jest', name: 'bar.jpg', type: 'image/jpeg', data: new Uint8Array() }) core.addFile({ source: 'file3', name: 'file3.jpg', type: 'image/jpeg', data: new Uint8Array() }) - return expect(core.upload()).resolves.toMatchSnapshot() + // uploadID is random, we don't want randomness in the snapshot + const validateNanoID = r => ( + typeof r.uploadID === 'string' && r.uploadID.length === 21 ? ({ ...r, uploadID: 'cjd09qwxb000dlql4tp4doz8h' }) : r + ) + + return expect(core.upload().then(validateNanoID)).resolves.toMatchSnapshot() }) it('should not upload if onBeforeUpload returned false', () => {