Dark mode
vitest.config.ts
ts
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
// กำหนดสภาพแวดล้อมสำหรับการทดสอบ (node, jsdom, happy-dom)
environment: "node",
// ไฟล์ที่ต้องการให้โหลดก่อนรันเทสต์
setupFiles: ["./setup.ts"],
// ไดเร็กทอรี่ที่ต้องการยกเว้นจากการทดสอบ
exclude: ["**/node_modules/**", "**/dist/**"],
// กำหนดค่าสำหรับการทำ coverage
coverage: {
provider: "v8", // หรือ 'istanbul'
reporter: ["text", "json", "html"],
reportsDirectory: "./coverage",
},
// กำหนดค่า timeout สำหรับการทดสอบ (หน่วยเป็นมิลลิวินาที)
testTimeout: 10000,
// เปิด/ปิด watch mode
watch: true,
// กำหนดรูปแบบการแสดงผล
reporters: ["default"],
// จำนวน threads ที่ใช้ในการรันเทสต์
threads: true,
// กำหนดรูปแบบของไฟล์ที่จะถูกรันเป็นเทสต์
include: ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
// กำหนดค่า globals สำหรับการเทสต์
globals: true,
// เปิด/ปิดการทำงานของ pool
pool: "threads",
// กำหนดค่าสำหรับการทำ benchmark
benchmark: {
include: ["**/*.bench.{js,ts}"],
reporters: ["default"],
},
},
});