After several days of shaping a growing service architecture, I’ve finally reached a point where 24 test suites and 153 individual tests are green. This isn’t just a number — it’s a signal that the foundations are holding as complexity grows.
Why this matters
The system is based on a modular monorepo using NestJS and TypeORM. Each bounded context (roles, payments, subscriptions, users…) is isolated but interconnected. And each piece now has its service and controller thoroughly tested.
I’m using:
- Strict DTO validation with decorators
- Optional properties enforced to match real-world API behavior
- Fully mocked repositories, including relations like
ManyToOne,OneToMany, etc. - No usage of deprecated decorators or practices — clean and modern code so far
Example challenge: Type compatibility
One tricky part was ensuring that TypeORM entities and DTOs play nicely. For instance, a Subscription entity uses SubscriptionPlan, which itself includes a billingCycle enum. Mocking that without violating type constraints requires a precise shape — missing a nested property or using null where undefined is expected? That breaks the test.
What’s next
With controllers and services covered, I’ll turn attention to:
- Fine-tuning error filters and their test coverage
- e2e test strategies using realistic flows
- Automating validation of Swagger docs during CI
This isn’t test-driven development in the purist sense, but confidence is building up fast — and that’s what matters.

Dodaj komentarz