Repository navigation
Expand file tree
/
Copy pathvite.config.ts
More file actions
80 lines (71 loc) · 2.65 KB
/
Copy pathvite.config.ts
File metadata and controls
80 lines (71 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import adapter from "@sveltejs/adapter-auto";
import { sveltekit } from "@sveltejs/kit/vite";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import type { UserConfig } from "vite";
// Extend Vite config to support Vitest's test property
type VitestConfig = Omit<UserConfig, "plugins"> & {
// Use 'unknown' to avoid Plugin type conflicts from multiple Vite versions in pnpm
plugins?: unknown;
test?: {
include?: string[];
exclude?: string[];
testTimeout?: number;
hookTimeout?: number;
globals?: boolean;
pool?: "threads" | "forks";
poolOptions?: Record<string, unknown>;
isolate?: boolean;
maxConcurrency?: number;
bail?: number;
reporters?: string[];
outputFile?: string;
onConsoleLog?: (log: string, type: "stdout" | "stderr") => void;
};
};
const config: VitestConfig = {
plugins: [
sveltekit({
preprocess: vitePreprocess(),
adapter: adapter(),
}),
],
// SSR configuration - externalize native dependencies
ssr: {
external: ["canvas", "chardet", "iconv-lite"],
noExternal: [],
},
// FIXED test configuration - prevents hanging with execAsync
test: {
include: ["test/**/*.ts"], // Include all .ts files in test/ directory
exclude: ["**/node_modules/**"],
testTimeout: 30000, // 30 seconds max per test (reduce if possible)
hookTimeout: 10000, // Reduced to detect hangs faster
globals: true, // Enable describe, it, expect globally
// SIMPLE execution configuration - no complex pooling
// Switched from "forks" to "threads" for improved performance and parallelism.
// Note: Using "threads" may reduce process isolation, which can affect tests that spawn external processes.
// Ensure your tests do not rely on full process isolation, or revert to "forks" if needed.
pool: "threads", // Use threads instead of forks
poolOptions: {
threads: {
singleThread: false, // Allow some parallelism
minThreads: 1,
maxThreads: 4, // Increased parallelism for faster test execution
},
},
// Enable isolation with proper cleanup to prevent interference
isolate: true, // Ensure test isolation for reliability
maxConcurrency: 1, // Sequential execution for stability
// Don't bail early - let all tests complete
bail: 0,
// Basic reporting - no complex logging that might hang
reporters: ["verbose", "json"],
outputFile: "test-results.json",
onConsoleLog: (log: string, _type: "stdout" | "stderr") => {
if (log.includes("timeout") || log.includes("hanging")) {
console.error(`🚨 Potential hanging test: ${log}`);
}
},
},
};
export default config;