From 3cfedeb43ef6b25b40c500a7a88fd254fd2239a7 Mon Sep 17 00:00:00 2001 From: Nicolas Clerc Date: Mon, 20 Feb 2023 10:36:18 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=85(frontend)=20fix=20mock=20restore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A bug with resetAllMocks has been fixed in jest in https://github.com/facebook/jest/pull/13866 It seems like we were relying on it. --- .../src/data/sideEffects/uploadFile/index.spec.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/frontend/packages/lib_components/src/data/sideEffects/uploadFile/index.spec.ts b/src/frontend/packages/lib_components/src/data/sideEffects/uploadFile/index.spec.ts index a40aaba1cc..3474e5bda5 100644 --- a/src/frontend/packages/lib_components/src/data/sideEffects/uploadFile/index.spec.ts +++ b/src/frontend/packages/lib_components/src/data/sideEffects/uploadFile/index.spec.ts @@ -21,12 +21,10 @@ describe('sideEffects/uploadFile', () => { }; const mockXHRClass = jest.fn().mockImplementation(() => mockXHRInstance); - beforeAll(() => { + beforeEach(() => { (window as any).XMLHttpRequest = mockXHRClass; }); - afterEach(jest.restoreAllMocks); - it('makes an xhr POST to perform the upload, notifies of progress and resolves', async () => { // Create the promise but don't await it so we can simulate the ongoing request const response = uploadFile(