Skip to main content

Suites

A unit-testing framework for TypeScript backend systems working with dependency injection

Works with projects using

NestJSNestJSOfficial
InversifyJSInversifyJSOfficial
VitestVitest
JestJest
SinonSinon
+
more
import { TestBed, type Mocked } from '@suites/unit';

describe('User Service', () => {
let userService: UserService; // ๐Ÿงช The unit we are testing
let userApi: Mocked<UserApi>; // ๐ŸŽญ The dependencies we are mocking
let database: Mocked<Database>;

beforeAll(async () => {
// ๐Ÿš€ Create an isolated test env for the unit
const { unit, unitRef } = await TestBed.solitary(UserService).compile();

userService = unit;
// ๐Ÿ” Retrieve the unit's dependency mocks - automatically generated
userApi = unitRef.get(UserApi);
database = unitRef.get(Database);
});

// โœ… Test test test
it('should generate a random user and save to the database', async () => {
userApi.getRandom.mockResolvedValue({id: 1, name: 'John'} as User);
await userService.generateRandomUser();
expect(database.saveUser).toHaveBeenCalledWith(userFixture);
});
});
๐Ÿ‘ฉโ€๐Ÿ’ป

Declarative

An opinionated declarative API: wrap your unit with a single call and receive a correct test environment for testing the unit. No more manual mocking and wiring up dependencies.

โœ…

Type-Safe

Create type-safe mocks, bound to the implementation and allows calling only the correct dependency methods. No more broken tests after refactors and no more silent failures.

๐Ÿ•ต๏ธโ€โ™‚๏ธ

Smart Mock Tracking

Automatically track all dependency methods used during your tests and get notified if a mocked dependency method has no return value or missing mock implementation

โœจ

AI Ready

With the concise, type safe, and fail-fast format of Suites tests, coding agents (like Claude Code and Cursor) are able to write correct tests in a single pass.

Trusted by

Monday.com
Lemonade
Balance
Harmonya

Zero-Setup, Automatic Mocking

Say goodbye to manual mocking. Suites automatically generates mocks for all your dependencies, letting you focus on writing meaningful tests, not boilerplate.

Learn about Mocking โ†’
// No manual mocks needed!
// Just compile the testbed for your class.
const { unit, unitRef } = await TestBed
.solitary(UserService)
.compile();

// Retrieve any dependency as a fully-typed mock.
const userApi = unitRef.get(UserApi);

// Focus on the test logic.
userApi.get.mockResolvedValue({ name: 'John' });

Flexible and Scalable by Design

Whether you're working on a small microservice or a large-scale monolith, Suites' flexible architecture adapts to your needs, ensuring your test suites remain maintainable as your project grows.

Explore Test Strategies โ†’
// Test a class in complete isolation
TestBed.solitary(OrderService).compile();

// Or, test how it integrates with a real dependency
TestBed.sociable(OrderService)
.expose(PaymentProcessor) // Use the real class
.compile();

An Intuitive, Fluent API

Suites provides a clean and semantic API that makes writing tests a pleasure. The intuitive design of the TestBed builder keeps your test code readable and maintainable.

Browse the API Reference โ†’
const { unit, unitRef } = await TestBed
.solitary(ComplexService)
.mock(Logger) // Override with a custom mock
.final({
// Provide custom values or configurations
token: 'API_KEY',
value: 'test-api-key'
})
.compile();