# Tests - Annas RechnungsManager Vitest-basiertes Test-Framework für kritische Geschäftslogik. ## Setup ```bash # Install dependencies (already done) npm install # Run tests npm run test # Single run npm run test:watch # Watch mode npm run test:ui # Browser UI npm run test:coverage # With coverage report ``` ## Test Structure ``` tests/ ├── lib/ │ ├── tax.test.ts # Steuerberechnungen (§14 UStG) │ └── schemas.test.ts # Zod-Validierung (Input-Sicherheit) └── README.md ``` ## Coverage - ✅ **tax.ts** - German tax calculations (19%, 7%, Kleinunternehmer) - ✅ **schemas.ts** - Input validation (Zod schemas) - ⚠️ **invoice-number.server.ts** - Requires Prisma mocking (TODO) ## Critical Test Areas 1. **Tax Calculations** - Must be correct per German tax law 2. **Input Validation** - Prevent invalid data in DB 3. **Invoice Logic** - §14 UStG compliance 4. **Buchhaltung** - Double-entry bookkeeping accuracy ## Running Specific Tests ```bash # Run only tax tests npx vitest run tests/lib/tax.test.ts # Run with coverage npm run test:coverage # Opens: ./coverage/index.html ``` ## Writing New Tests ```typescript import { describe, it, expect } from "vitest"; import { myFunction } from "@/lib/my-module"; describe("myModule", () => { it("should do something", () => { expect(myFunction()).toBe(expected); }); }); ``` ## CI Integration Tests laufen automatisch in der Gitea Actions Pipeline (`.gitea/workflows/build.yml`).