diff --git a/__tests__/uploader.spec.ts b/__tests__/uploader.spec.ts index 645d33ca..0964ddc5 100644 --- a/__tests__/uploader.spec.ts +++ b/__tests__/uploader.spec.ts @@ -46,7 +46,7 @@ describe('Uploader', () => { it('fails if not logged in and not on public share', async () => { vi.spyOn(nextcloudAuth, 'getCurrentUser').mockImplementationOnce(() => null) - expect(async () => new Uploader()).rejects.toThrow(/User is not logged in/) + await expect(async () => new Uploader()).rejects.toThrow(/User is not logged in/) }) }) @@ -119,7 +119,7 @@ describe('Uploader', () => { mime: 'text/plain', }) - expect(() => { uploader.destination = newDestination as nextcloudFiles.Folder }).toThrowError(/invalid destination/i) + expect(() => { uploader.destination = newDestination as unknown as nextcloudFiles.Folder }).toThrowError(/invalid destination/i) }) }) }) diff --git a/vitest.config.ts b/vitest.config.ts index 10e1cc4e..cf420b1e 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -6,25 +6,23 @@ import type { UserConfig } from 'vitest/node' import config from './vite.config.ts' export default async (env) => { - const cfg = await config(env) - // Node externals does not work with vitest - cfg.plugins = cfg.plugins!.filter((plugin) => plugin && 'name' in plugin && plugin.name !== 'node-externals') - - cfg.test = { - environment: 'jsdom', - environmentOptions: { - jsdom: { - url: 'https://cloud.example.com/index.php/apps/test', + return { + ...await config(env), + test: { + environment: 'jsdom', + environmentOptions: { + jsdom: { + url: 'https://cloud.example.com/index.php/apps/test', + }, + }, + setupFiles: '__tests__/setup.ts', + coverage: { + include: ['lib/**'], + // This makes no sense to test + exclude: ['lib/utils/l10n.ts'], + reporter: ['lcov', 'text'], }, - }, - setupFiles: '__tests__/setup.ts', - coverage: { - include: ['lib/**'], - // This makes no sense to test - exclude: ['lib/utils/l10n.ts'], - reporter: ['lcov', 'text'], - }, - pool: 'vmForks', - } as UserConfig - return cfg + pool: 'vmForks', + } as UserConfig, + } }