Testing
Test suites, strategy, and how to run tests
Overview
840 tests across 2 test suites, all passing with 0 failures.
| Suite | Tests | Location | Runner |
|---|---|---|---|
| Fiscal | 754 | packages/fiscal/ | bun test |
| tRPC | 86 | apps/web/ | bun test |
Run fiscal and tRPC tests separately — Bun can segfault on large parallel runs.
Running Tests
# tRPC router tests
cd apps/web && bun test
# Fiscal module tests
cd packages/fiscal && bun test
# Coverage report
cd apps/web && bun run test:coverageTest Architecture
Loading diagram...
Fiscal Tests
The fiscal test suite (754 tests) covers:
- Tax calculations — all 15 ICMS CST + 10 CSOSN variants, PIS, COFINS, IPI, II
- XML generation — complete NF-e/NFC-e XML structure validation
- XML complement — protocol attachment, digest verification
- QR code — v2.00/v3.00 generation (online + offline)
- Certificate — PFX extraction, XML digital signature
- Value objects — AccessKey (mod-11), TaxId (CPF/CNPJ)
- Utilities — GTIN validation, state codes, standardization
- TXT conversion — 4 legacy SPED layouts
Tests were ported from the PHP sped-nfe library, ensuring feature parity.
tRPC Tests
The tRPC test suite (86 tests) uses PGLite in-memory for isolation:
- A
mock.moduleoverrides@/lib/dbwith an in-memory PGLite instance createCallerFactorycreates a direct procedure caller (no HTTP)- Each test verifies CRUD operations, multi-tenant isolation (
user_uid), and Zod input validation