Files
sass-mohfarawati/vitest.config.ts
T

55 lines
1.5 KiB
TypeScript

import path from "path";
import { fileURLToPath } from "url";
import { defineConfig } from "vitest/config";
const rootDir = path.dirname(fileURLToPath(new URL(import.meta.url)));
const alias = { "@": rootDir };
const esbuild = { jsx: "automatic" as const };
export default defineConfig({
resolve: { alias },
esbuild,
test: {
// Root-level (not valid inside a single `projects[]` entry — it's a global
// option). One shared integration test database means test files must run
// sequentially (never in parallel) so each file's truncation between tests
// never races another file's.
fileParallelism: false,
projects: [
{
resolve: { alias },
esbuild,
test: {
name: "unit",
environment: "node",
include: ["tests/unit/**/*.test.ts", "tests/*.test.ts"],
},
},
{
resolve: { alias },
esbuild,
test: {
name: "integration",
environment: "node",
include: ["tests/integration/**/*.test.{ts,tsx}"],
globalSetup: ["tests/helpers/global-db-setup.ts"],
setupFiles: ["tests/helpers/integration-setup.ts"],
hookTimeout: 60_000,
testTimeout: 30_000,
},
},
{
resolve: { alias },
esbuild,
test: {
name: "component",
environment: "jsdom",
include: ["tests/component/**/*.test.{ts,tsx}"],
setupFiles: ["tests/helpers/component-setup.ts"],
},
},
],
},
});