Skip to content

Commit a636c4b

Browse files
committed
🐛 Place the @sveltejs/kit mock before importing modules that use it (#2446)
1 parent 1483a0b commit a636c4b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/test/lib/utils/authorship.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import { expect, test, describe, vi } from 'vitest';
22

3+
// Mock modules
4+
vi.mock('@sveltejs/kit', () => ({
5+
redirect: vi.fn().mockImplementation((status: number, location: string) => {
6+
throw new Error(`Redirect ${status} ${location}`);
7+
}),
8+
}));
9+
310
import {
411
ensureSessionOrRedirect,
512
getLoggedInUser,
@@ -17,13 +24,6 @@ import type {
1724
} from '$lib/types/authorship';
1825
import { Roles } from '$lib/types/user';
1926

20-
// Mock modules
21-
vi.mock('@sveltejs/kit', () => ({
22-
redirect: vi.fn().mockImplementation((status: number, location: string) => {
23-
throw new Error(`Redirect ${status} ${location}`);
24-
}),
25-
}));
26-
2727
const adminId = '1';
2828
const userId1 = '2';
2929
const userId2 = '3';

0 commit comments

Comments
 (0)