diff --git a/src/domain/singups/__mocks__/testUtils.ts b/src/domain/singups/__mocks__/testUtils.ts index 98fbd857..c6c56828 100644 --- a/src/domain/singups/__mocks__/testUtils.ts +++ b/src/domain/singups/__mocks__/testUtils.ts @@ -49,7 +49,12 @@ export const shouldExportSignupsAsExcel = async ( // Mock document.createElement which is needed by downloadBlob. RenderComponent needs // createElement so do this after rendering components to avoid errors const createElement = document.createElement; - document.createElement = vi.fn().mockImplementation(() => link); + document.createElement = vi + .fn() + .mockImplementation((tagName: string, ...args: any[]) => { + if (tagName === 'a') return link; + return createElement.call(document, tagName, ...args); + }); await user.click(exportAsExcelButton); diff --git a/src/utils/testUtils.tsx b/src/utils/testUtils.tsx index 45ea5dfa..05fe964f 100644 --- a/src/utils/testUtils.tsx +++ b/src/utils/testUtils.tsx @@ -143,11 +143,11 @@ const actWait = (amount?: number): Promise => act(() => wait(amount)); const mockNumberString = (size: number): string => [...Array(size)] - .map(() => Math.floor(Math.random() * 10).toString()) + .map(() => Math.floor(Math.random() * 10).toString()) // NOSONAR .join(''); const mockString = (size: number): string => - [...Array(size)].map(() => Math.random().toString(36)[2]).join(''); + [...Array(size)].map(() => Math.random().toString(36)[2]).join(''); // NOSONAR const loadingSpinnerIsNotInDocument = async (timeout = 1000): Promise => waitFor(