From c71b5c17757455de5c6c3287fd9118eacc50c409 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Wed, 11 Sep 2024 22:57:55 +0200 Subject: [PATCH] fix tests --- packages/sveltekit/test/vite/sourceMaps.test.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/sveltekit/test/vite/sourceMaps.test.ts b/packages/sveltekit/test/vite/sourceMaps.test.ts index c25ec48a53cb..2d12c9835b58 100644 --- a/packages/sveltekit/test/vite/sourceMaps.test.ts +++ b/packages/sveltekit/test/vite/sourceMaps.test.ts @@ -17,6 +17,15 @@ vi.mock('@sentry/vite-plugin', async () => { }; }); +vi.mock('sorcery', async () => { + return { + load: vi.fn().mockResolvedValue({ + apply: vi.fn().mockResolvedValue(undefined), + write: vi.fn().mockResolvedValue(undefined), + }), + }; +}); + beforeEach(() => { vi.clearAllMocks(); }); @@ -79,7 +88,7 @@ describe('makeCustomSentryVitePlugin()', () => { // @ts-expect-error this function exists! plugin.configResolved({ build: { ssr: true } }); // @ts-expect-error this function exists! - plugin.closeBundle(); + await plugin.closeBundle(); expect(mockedSentryVitePlugin.writeBundle).toHaveBeenCalledTimes(1); }); @@ -89,7 +98,7 @@ describe('makeCustomSentryVitePlugin()', () => { // @ts-expect-error this function exists! plugin.configResolved({ build: { ssr: false } }); // @ts-expect-error this function exists! - plugin.closeBundle(); + await plugin.closeBundle(); expect(mockedSentryVitePlugin.writeBundle).not.toHaveBeenCalled(); }); }); @@ -110,7 +119,7 @@ describe('makeCustomSentryVitePlugin()', () => { // @ts-expect-error this function exists! plugin.configResolved({ build: { ssr: true } }); // @ts-expect-error this function exists! - plugin.closeBundle(); + await plugin.closeBundle(); expect(consoleWarnSpy).toHaveBeenCalledWith(expect.stringContaining('Failed to upload source maps')); expect(consoleLogSpy).toHaveBeenCalled();