Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/vitest.config.ts
T

129 lines
9.5 KiB
TypeScript

import { coverageConfigDefaults, defineConfig } from "vitest/config";
import path from "path";
const coreOnlyExclude = [
"apps/web/app/routes/__forms/**",
"apps/web/app/routes/admin/__workflows/**",
"apps/web/app/routes/app.$tenant/__portals/**",
"apps/web/app/routes/app.$tenant/__workflows/**",
"apps/web/app/routes/internal/api/__workflows/**",
"apps/web/app/modules/formBuilder/**",
"apps/web/app/modules/portals/**",
"apps/web/app/modules/sites/**",
"apps/web/app/modules/surveys/**",
"apps/web/app/modules/workflowEngine/**",
];
const coreTestExcludes = process.env.HIVEGRID_CORE_TESTS_ONLY === "1" ? coreOnlyExclude : [];
const coverageGateEnabled = process.env.HIVEGRID_COVERAGE_GATE === "1";
const coverageArtifactExcludes = [
"**/node_modules/**",
"**/dist/**",
"**/build/**",
"**/.react-router/**",
"**/storybook-static/**",
"**/coverage/**",
"**/coverage-gate/**",
"**/generated/**",
"**/*.generated.*",
];
export default defineConfig({
test: {
globals: true,
// CI-load headroom: the full apps/web + scripts suite runs with default
// parallelism on the Gitea runner, where CPU contention pushes otherwise-fast
// tests past the 5s default and flakes them ("Test timed out in 5000ms" — seen on
// feature-flags + decision-report verify tests). 20s removes that class of flake
// without slowing anything (only genuinely-slow tests consume the extra budget).
testTimeout: 20_000,
hookTimeout: 20_000,
// Keep CPU headroom for Vite's transform/RPC process. Saturating this host
// with Vitest's default N-1 forks caused transform fetch timeouts and made
// the 685-file core suite ~10x slower; 50% completed the same suite cleanly.
maxWorkers: "50%",
environment: "jsdom",
exclude: ["**/node_modules/**", "**/dist/**", "**/.react-router/**", "**/.claude/**", "tests/e2e/**", ...coreTestExcludes],
setupFiles: [path.resolve(__dirname, "vitest.setup.ts")],
coverage: {
// Vitest 3 uses `@vitest/coverage-v8` (V8 native coverage). The legacy
// c8 provider was retired in vitest 1.0 and the `coverage-c8` package
// is unmaintained.
//
// Reporter list per docs/architecture/test-coverage.md:
// - text-summary: human-readable terminal output
// - json-summary: feeds scripts/verify-test-coverage.mjs + readme badge
// - html: drillable artifact, uploaded by .gitea/workflows/coverage.yml
// - lcov: consumed by external tools (Codecov, IDE plugins)
// The CI threshold gate sets HIVEGRID_COVERAGE_GATE=1 to avoid writing
// heavyweight HTML/LCOV artifacts during the quick threshold check.
provider: "v8",
reporter: coverageGateEnabled ? ["text-summary", "json-summary"] : ["text-summary", "json-summary", "html", "lcov"],
reportsDirectory: coverageGateEnabled ? "coverage-gate" : "coverage",
exclude: [...coverageConfigDefaults.exclude, ...coverageArtifactExcludes],
},
},
resolve: {
alias: {
"~": path.resolve(__dirname, "./apps/web/app"),
"vite-env-only/macros": path.resolve(__dirname, "./tests/vite-env-only-macros.ts"),
// AK-P21: tenant-scoped model registry consumed by the worker hard-delete.
"@hivegrid/cli/tenant-models": path.resolve(__dirname, "./packages/cli/src/commands/tenant/models.ts"),
"@hivegrid/error-reporter": path.resolve(__dirname, "./packages/error-reporter/src/index.ts"),
"@hivegrid/exports/audit-pdf": path.resolve(__dirname, "./packages/exports/src/audit-pdf.ts"),
"@hivegrid/exports/csv": path.resolve(__dirname, "./packages/exports/src/csv/index.ts"),
"@hivegrid/exports/json": path.resolve(__dirname, "./packages/exports/src/json/index.ts"),
"@hivegrid/exports/limits": path.resolve(__dirname, "./packages/exports/src/limits.ts"),
"@hivegrid/exports/pdf": path.resolve(__dirname, "./packages/exports/src/pdf/index.ts"),
"@hivegrid/exports/s3-multipart": path.resolve(__dirname, "./packages/exports/src/sinks/s3-multipart.ts"),
"@hivegrid/exports/types": path.resolve(__dirname, "./packages/exports/src/types.ts"),
"@hivegrid/exports/zip": path.resolve(__dirname, "./packages/exports/src/zip.ts"),
"@hivegrid/exports/xlsx": path.resolve(__dirname, "./packages/exports/src/xlsx/index.ts"),
"@hivegrid/exports": path.resolve(__dirname, "./packages/exports/src/index.ts"),
// Subpath exports for `@hivegrid/foundation` + `@hivegrid/integrations` (R-P5/AK-P17a):
// vitest resolves workspace subpaths via these explicit aliases, not package.json `exports`.
// More specific (longer) keys MUST precede the bare-package alias.
"@hivegrid/foundation/crypto": path.resolve(__dirname, "./packages/foundation/src/crypto/index.ts"),
"@hivegrid/foundation/marketing-token": path.resolve(__dirname, "./packages/foundation/src/marketing-token.ts"),
"@hivegrid/foundation/outbound-http": path.resolve(__dirname, "./packages/foundation/src/outbound-http.ts"),
"@hivegrid/foundation/spreadsheet-safety": path.resolve(__dirname, "./packages/foundation/src/spreadsheet-safety.ts"),
"@hivegrid/foundation/trusted-client-ip": path.resolve(__dirname, "./packages/foundation/src/trusted-client-ip.ts"),
"@hivegrid/foundation": path.resolve(__dirname, "./packages/foundation/src/index.ts"),
"@hivegrid/integrations/calendar-worker-tasks.server": path.resolve(__dirname, "./packages/integrations/src/calendar-worker-tasks.server.ts"),
"@hivegrid/integrations/email-worker-tasks.server": path.resolve(__dirname, "./packages/integrations/src/email-worker-tasks.server.ts"),
"@hivegrid/integrations/admin-email-attachments.server": path.resolve(__dirname, "./packages/integrations/src/admin-email-attachments.server.ts"),
"@hivegrid/integrations/admin-email-provider-events": path.resolve(__dirname, "./packages/integrations/src/admin-email-provider-events.ts"),
"@hivegrid/integrations/admin-email-tracking": path.resolve(__dirname, "./packages/integrations/src/admin-email-tracking.ts"),
"@hivegrid/integrations/admin-email-worker-tasks.server": path.resolve(__dirname, "./packages/integrations/src/admin-email-worker-tasks.server.ts"),
"@hivegrid/integrations/admin-call-recordings.server": path.resolve(__dirname, "./packages/integrations/src/admin-call-recordings.server.ts"),
"@hivegrid/integrations/admin-telephony-worker.server": path.resolve(__dirname, "./packages/integrations/src/admin-telephony-worker.server.ts"),
"@hivegrid/integrations/admin-outbound-calls.server": path.resolve(__dirname, "./packages/integrations/src/admin-outbound-calls.server.ts"),
"@hivegrid/integrations/admin-calendar-sync-worker.server": path.resolve(__dirname, "./packages/integrations/src/admin-calendar-sync-worker.server.ts"),
"@hivegrid/integrations/admin-booking-worker.server": path.resolve(__dirname, "./packages/integrations/src/admin-booking-worker.server.ts"),
"@hivegrid/integrations/email-match-hook.server": path.resolve(__dirname, "./packages/integrations/src/email-match-hook.server.ts"),
"@hivegrid/integrations/kwp-archive-discovery.server": path.resolve(__dirname, "./packages/integrations/src/kwp/archive-discovery.server.ts"),
"@hivegrid/integrations/kwp-archive-file.server": path.resolve(__dirname, "./packages/integrations/src/kwp/archive-file.server.ts"),
"@hivegrid/integrations/kwp-contract-sentinel.server": path.resolve(__dirname, "./packages/integrations/src/kwp/contract-sentinel.server.ts"),
"@hivegrid/integrations/kwp-inbound-reader": path.resolve(__dirname, "./packages/integrations/src/kwp/inbound-reader.ts"),
"@hivegrid/integrations/kwp-inbound-sync.server": path.resolve(__dirname, "./packages/integrations/src/kwp/inbound-sync.server.ts"),
"@hivegrid/integrations/kwp-project-catalog.server": path.resolve(__dirname, "./packages/integrations/src/kwp/project-catalog.server.ts"),
"@hivegrid/integrations/kwp-project-domain.server": path.resolve(__dirname, "./packages/integrations/src/kwp/project-domain.server.ts"),
"@hivegrid/integrations/kwp-project-sync.server": path.resolve(__dirname, "./packages/integrations/src/kwp/project-sync.server.ts"),
"@hivegrid/integrations/kwp-resource-client.server": path.resolve(__dirname, "./packages/integrations/src/kwp/resource-client.server.ts"),
"@hivegrid/integrations/worker-tasks.server": path.resolve(__dirname, "./packages/integrations/src/worker-tasks.server.ts"),
"@hivegrid/integrations": path.resolve(__dirname, "./packages/integrations/src/index.ts"),
"@hivegrid/realtime": path.resolve(__dirname, "./packages/realtime/src/index.ts"),
"@hivegrid/storage": path.resolve(__dirname, "./packages/storage/src/index.ts"),
"@hivegrid/url": path.resolve(__dirname, "./packages/url/src/index.ts"),
// Subpath exports for `@hivegrid/ui-app` — the workspace package ships
// unbuilt TS, so we explicitly map the test-helper subpaths used by
// *.axe.test.tsx suites (see docs/contributing/wcag-audit.md).
"@hivegrid/ui-app/test-setup/axe": path.resolve(__dirname, "./packages/ui-app/test-setup/axe.ts"),
"@hivegrid/ui-app/test-utils/a11y-template": path.resolve(__dirname, "./packages/ui-app/src/test-utils/a11y-template.ts"),
"@hivegrid/ui-app": path.resolve(__dirname, "./packages/ui-app/src/index.ts"),
"@hivegrid/ui-mock": path.resolve(__dirname, "./packages/ui-mock/src/index.ts"),
"@hivegrid/ui-subframe": path.resolve(__dirname, "./packages/ui-subframe/src/index.ts"),
"@hivegrid/view-models": path.resolve(__dirname, "./packages/view-models/src/index.ts"),
},
},
});