Skip to content

Commit 2ed4cea

Browse files
committed
test: add setup file configuration to vite test config
1 parent 35f336d commit 2ed4cea

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { vi } from "vitest";
2+
3+
// Mock Vue Router composables only, preserve real exports
4+
vi.mock("vue-router", async (importOriginal) => {
5+
const actual = await importOriginal<typeof import("vue-router")>();
6+
return {
7+
...actual,
8+
useRouter: () => ({
9+
push: vi.fn(),
10+
replace: vi.fn(),
11+
go: vi.fn(),
12+
back: vi.fn(),
13+
forward: vi.fn(),
14+
currentRoute: { value: { path: "/", params: {}, query: {}, meta: {} } },
15+
}),
16+
useRoute: () => ({ path: "/", params: {}, query: {}, meta: {} }),
17+
};
18+
});
19+
20+
// Set up proper HTML doctype for KaTeX
21+
document.documentElement.innerHTML = "<!DOCTYPE html><html><head></head><body></body></html>";

new-deepnotes/apps/web/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default defineConfig({
2828
test: {
2929
environment: "happy-dom",
3030
include: ["src/**/*.test.ts"],
31+
setupFiles: ["./src/test/setup.ts"],
3132
testTimeout: 120000,
3233
hookTimeout: 120000,
3334
pool: "forks",

0 commit comments

Comments
 (0)