Files
butcem/vitest.integration.config.mts

45 lines
1.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { tmpdir } from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { loadEnv } from "vite";
import { defineConfig } from "vitest/config";
/**
* Entegrasyon testleri: gerçek MongoDB (npm run db:up) üzerinde, ayrı "butcem_test" veritabanı.
* Çalıştırma: npm run test:integration
*/
const fileEnv = loadEnv("test", process.cwd(), "");
const local = { ...loadEnv("development", process.cwd(), ""), ...fileEnv };
const baseUri =
process.env.MONGODB_URI_TEST ??
(
local.MONGODB_URI ?? "mongodb://localhost:27019/butcem?replicaSet=rs0&directConnection=true"
).replace(/\/([^/?]+)(\?|$)/, "/butcem_test$2");
export default defineConfig({
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
"server-only": fileURLToPath(new URL("./src/test/server-only-stub.ts", import.meta.url)),
},
},
test: {
environment: "node",
include: ["src/**/*.int.test.ts", "scripts/**/*.int.test.ts"],
fileParallelism: false,
testTimeout: 20_000,
hookTimeout: 30_000,
env: {
NODE_ENV: "test",
MONGODB_URI: baseUri,
BETTER_AUTH_SECRET: "test-secret-test-secret-test-secret-0123",
BETTER_AUTH_URL: "http://localhost:3000",
SEED_ADMIN_EMAIL: "admin@test.local",
SEED_ADMIN_PASSWORD: "Test-Admin-12345",
SEED_USER_PASSWORD: "Test-User-12345",
// Ek dosyalar geçici dizine (her çalıştırmada test dosyası temizler).
UPLOAD_DIR: path.join(tmpdir(), "butcem-test-uploads"),
},
},
});