4 ms·
Show HN: Suites – modern unit tests framework for TypeScript back ends
Hey HN!
Suites is a unit-testing framework for TypeScript backend systems working with dependency injection.
It introduces a single declarative API for unit testing: wrap any unit with a single call and receive a correct test environment for the unit and its dependencies.
// Test a class in complete isolation, all dependencies mocked
TestBed.solitary(OrderService).compile();
// Or, test how it integrates with a real dependency
TestBed.sociable(OrderService)
.expose(PaymentProcessor) // Use the real class
.compile();
The backstory: while working for a fast-growing fintech startup 4 years ago, my team had to write thousands of unit tests for our NestJS backend. To scale our efforts, I've built a unit-testing framework which eliminated a significant part of the tests' code and made them a whole lot more maintainable. I open-sourced it, generalized it to support more tech stacks, and soon it gained traction.
The problem - unit testing becomes a nightmare very fast:
- You mock dependencies by hand, wire them up manually, and spend more time maintaining tests than writing them.
- Unit tests are leaky and error-prone since it's unclear which dependencies are mocked
- Test intention is lost in the boilerplate
- Each engineer invents their own conventions
- Tests break during refactors because of untyped, loosely connected mocks
- Missing mock implementations go unnoticed, so tests falsely fail on unexpected undefined returns or validate the wrong behavior
- Test errors for wrong mocking are confusing to engineers and coding agents alike
The nitty-gritty details:
- Fluent, auto-discoverable, fully-typed API.
- DI Framework Adapters: Works out of the box with NestJS and InversifyJS
- Testing Library Adapters: Works out of the box with Jest, Sinon, and Vitest
Suites provide two modes of testing: (inspired by Martin Fowler's writings [0])
- Solitary: For testing units in a vacuum, it creates type-safe mocks of all the unit's direct dependencies.
- Sociable: For testing units with other related units, it allows the developer to define which dependencies to mock.
Eliminating boilerplate and making mocks type-safe drastically helps coding agents (e.g. Claude Code) to write correct tests in a single pass and avoid entering infinite loops, significantly reducing token cost.
You can read more about Suites on our website: https://suites.dev https://suites.dev
What's next?
- A dedicated skill for Claude Code
- Extended docs with real-world patterns
- More test utilities for common backend scenarios
Suites is fully open-source and actively maintained for 4 years. I would love you to check it out and get your honest feedback!
[0] https://martinfowler.com/bliki/UnitTest.html https://martinfowler.com/bliki/UnitTest.html
- iddan 11mo agoSuites has been such a help in my Nest.js projects. I can't tell you how many times we would run into issues because some mock was not properly configured. The amount boilerplate it's saving is life saving
- rlapuente 11mo agoWe used Suites heavily and it's an amazing tool for Nest, we couldn't leave without it
- wolffan 11mo agoIf you're vibe coding without this, you better get it now! Can't wait for bun support