npx create-next-app --ts
npm i -D vitest @vitejs/plugin-react @testing-library/react @testing-library/user-event jsdom
/// <reference types="vitest" />
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
test: {
globals: true, // use `describe, it, test` without importing them
environment: "jsdom",
setupFiles: "./tests/setup.ts",
},
});
{
"compilerOptions": {
// ...
"types": ["vitest/globals"]
}
}