-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathvitest.config.js
More file actions
62 lines (53 loc) · 1.51 KB
/
vitest.config.js
File metadata and controls
62 lines (53 loc) · 1.51 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
/**
* Vitest Configuration
* ======================
*
* Configuration for the Vitest testing framework.
* Vitest is a Vite-native testing framework that's fast and compatible
* with the existing Vite setup.
*
* Features:
* - React Testing Library support via jsdom environment
* - Global test utilities (describe, it, expect)
* - Path aliases matching vite.config.js
* - Coverage reporting ready
*
* Run tests:
* npm test # Run tests in watch mode
* npm run test:ui # Open Vitest UI
* npm run test:coverage # Generate coverage report
*/
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import path from "path";
export default defineConfig({
plugins: [react()],
test: {
// Use jsdom for DOM testing (React components)
environment: "jsdom",
// Make test globals available (describe, it, expect, etc.)
globals: true,
// Setup file to run before each test file
setupFiles: ["./src/client/__tests__/setup.js"],
// Include patterns for test files
include: ["src/**/*.{test,spec}.{js,jsx}"],
// Exclude patterns
exclude: ["node_modules", "dist"],
// Coverage configuration
coverage: {
reporter: ["text", "json", "html"],
exclude: [
"node_modules/",
"src/**/__tests__/**",
"src/**/*.test.{js,jsx}",
"src/**/*.spec.{js,jsx}",
],
},
},
// Path aliases (same as vite.config.js)
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
});