Skip to content

v4.1.0

Choose a tag to compare

@suites-release-bot suites-release-bot released this 05 Nov 07:08
· 50 commits to master since this release
v4.1.0
7719593

v4.1.0 (2026-11-05)

Documentation: https://suites.dev/docs

Suites 4.1 adds InjectionJS support through the new @suites/di.injectionjs adapter. Test constructor-injected services with Jest or Vitest, including dependencies identified by InjectionToken. This release also adds adapter-defined token types and preserves token identity in mock overrides and lookups. CommonJS and ESM remain supported.

InjectionJS support: Requires InjectionJS ^2.6.1 and supports constructor injection. Contextual inject() calls, including class field initializers, are not supported.

Features

  • di.injectionjs, unit
    • Adds automatic discovery of the InjectionJS adapter. Supports class dependencies, @Inject() with class, nonempty string, symbol, or InjectionToken identifiers, and forwardRef() constructor tokens. Static parameters and lowered ctorParameters metadata are also supported. (#934)
    • Supports mock implementations, final values, and real class dependencies exposed through TestBed.sociable(). Exports a /metadata declaration entry point for InjectionJS token types. (27c0fdd)
  • core.unit
    • Preserves object token identity in overrides and lookups. Two InjectionToken instances with the same description remain distinct dependencies. (b7a7971)
  • unit, doubles.jest, doubles.vitest
    • Accepts adapter-registered tokens in typed mock configuration and dependency lookups. Use an explicit dependency type with InjectionJS tokens, such as unitRef.get<UserRepository>(USER_REPOSITORY). (81aefe3, cc0f1de, ad36afe)
  • types.di
    • Custom DI adapters can augment InjectableIdentifierRegistry<T> to register their own dependency token types. (76ea267)

Getting Started with InjectionJS

For InjectionJS + Jest:

pnpm add -D @suites/unit @suites/di.injectionjs @suites/doubles.jest

Your application must also have injection-js and reflect-metadata installed. Add suites.d.ts to the files included by your test tsconfig:

/// <reference types="@suites/doubles.jest/unit" />
/// <reference types="@suites/di.injectionjs/metadata" />

Enable experimentalDecorators and emitDecoratorMetadata, configure your test transformer to emit decorator metadata, and load reflect-metadata before your decorated classes.

For InjectionJS + Vitest, install @suites/doubles.vitest instead of the Jest adapter and use @suites/doubles.vitest/unit for the first reference. Add this setting to your existing Vitest configuration so the test runner and adapter share the same InjectionJS module:

import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    server: { deps: { external: ['injection-js'] } },
  },
  // Keep your existing decorator metadata transformer and test settings.
});

See the InjectionJS adapter guide for a complete test example and support boundaries. Suites builds a flat test container; production provider factories, multi-providers, and injector hierarchy rules are not reproduced.

Enhancements

  • *
    • Adds packed-package InjectionJS E2E coverage with Jest and Vitest, in CommonJS and ESM, across Node.js 22, 24, and 26. Compatibility checks cover InjectionJS 2.6.1 and the current 2.x release. (9397487)
  • di.nestjs, di.inversify
    • Releases version 4.0.1 to consume the updated shared DI types. These patches contain dependency updates only; supported framework versions remain unchanged. (#1104)

Full Changelog: v4.0.0...v4.1.0