Tutorials
Run the Tests
Run unit tests, typecheck, lint, and a production build for kredal-app.
Kredal's business logic — the scoring engine and report templates — is covered by fast, pure-function unit tests that need no database.
Unit tests (Vitest)
cd kredal-app
npm testThis runs vitest run. It covers:
- Scoring engine (
src/lib/scoring/engine.test.ts): category scores, the risk-band thresholds, and specific rules (missing trade license, missing UBO declaration, missing source-of-funds, high-risk activity). - Report templates (
src/lib/reports/templates.test.ts): the mandatory disclaimer is present, and the company name and score render.
Typecheck
npx tsc --noEmitLint
npm run lintProduction build
The build also runs a full TypeScript check across the whole app:
npm run buildWhen to run what
| Change | Run |
|---|---|
| Scoring or report logic | npm test then npm run build |
| Any component or page | npm run build (catches route + RSC errors) |
| Docs only | See docs CI — npm test not required |
If you change the scoring engine, also regenerate its reference doc — see Add a scoring rule.