Migrating from Automock to Suites

Introduction

Suites succeeds Automock as the actively developed testing framework. Support for Automock 2.x ended on June 30, 2026. All new development continues in Suites, starting from version 3.0.0.

This guide migrates Automock tests to the TestBed API used by Suites 4. Also complete the Suites 4 setup steps for supported runtime versions, explicit type references, and adapter changes.

For detailed setup instructions, see the Installation Guide.

The Shift from Automock

Version 3.0.0 of Suites was the first release after Automock’s v2.1.2 completion, with subsequent improvements in 3.0.1 and beyond. Each new version comes with more features and better support. Automock v2.1.x no longer receives fixes. All new development focuses on Suites.

Migration Guide

Automate the migration

Start with a clean Git working tree. Preview and apply the Automock transform:

Terminal window
# Preview the changes first (no files written)
npx @suites/codemod@latest automock/2/to-suites-v3 'src/**/*.spec.ts' --dry --print
# Apply
npx @suites/codemod@latest automock/2/to-suites-v3 'src/**/*.spec.ts'

This transform rewrites imports, converts TestBed.create() to async TestBed.solitary().compile(), and updates mock configuration and types. It targets the Suites 3 TestBed API, which Suites 4 retains.

Next, update your dependencies, review and commit those changes, then run the v4 codemod. The v4 transform is available in @suites/codemod 0.2.0 and later:

Terminal window
# Preview v4 references and helper imports
npx @suites/codemod@latest suites/3/to-suites-v4 ./src --dry --print
# Apply after reviewing the preview
npx @suites/codemod@latest suites/3/to-suites-v4 ./src

Adjust the target to include your tests and declaration files. Complete the remaining v4 migration steps and run your TypeScript check and tests. Neither transform migrates Sinon-specific stubs or assertions.

Step 1: Update Dependencies

Replace Automock dependencies with Suites equivalents.

See Installation Guide for detailed adapter information:

Terminal window
# Remove Automock packages
npm uninstall @automock/jest @automock/sinon
# Install Suites core
npm install --save-dev @suites/unit
# Then install adapters for your stack:
# NestJS + Jest
npm install --save-dev @suites/doubles.jest @suites/di.nestjs
# NestJS + Vitest
npm install --save-dev @suites/doubles.vitest @suites/di.nestjs
# InversifyJS + Jest
npm install --save-dev @suites/doubles.jest @suites/di.inversify
# InversifyJS + Vitest
npm install --save-dev @suites/doubles.vitest @suites/di.inversify

Suites splits the doubles library and the DI integration into separate packages, so install one @suites/doubles.* and one @suites/di.* matching your stack. Suites 4 does not support Sinon: migrate Sinon-specific tests to Jest or Vitest and follow the installation instructions for runner dependencies and type references.

Step 2: Update Imports

Change all imports from Automock packages to the unified Suites import:

// Before
import { TestBed } from '@automock/jest';
// OR
import { TestBed } from '@automock/sinon';
// After
import { TestBed, type Mocked } from '@suites/unit';

Step 3: Update TestBed API Calls

Update TestBed API calls to match the new syntax. The beforeAll or beforeEach callback must be async:

// Before
beforeAll(() => {
const {unit} = TestBed.create(Service).compile();
});
// After
beforeAll(async () => {
const {unit} = await TestBed.solitary(Service).compile();
});

Step 4: Update Mock Implementation

Update any mock implementation code to use the new syntax:

// Before
TestBed.create(UserService)
.mock(UserRepository)
.using({
getUserById: () => Promise.resolve({id: 1, name: 'John'}),
})
.compile();
// After
await TestBed.solitary(UserService)
.mock(UserRepository)
.final({
getUserById: () => Promise.resolve({id: 1, name: 'John'}),
})
.compile();
// OR using .impl() for more flexibility
await TestBed.solitary(UserService)
.mock(UserRepository)
.impl((stubFn) => ({
getUserById: stubFn().mockResolvedValue({id: 1, name: 'John'}),
}))
.compile();

Major Changes from Automock to Suites

Versioning

  • Automock stopped at version 2.1.2 and is no longer maintained.
  • Suites started at version 3.0.0; this guide now targets Suites 4.

Breaking Changes

TestBed.compile() is now async: Due to dynamic importing, you must use async/await with compile():

// Before
const {unit} = TestBed.create(Service).compile();
// After
const {unit} = await TestBed.solitary(Service).compile();

TestBed.create() is now TestBed.solitary(): This change supports the distinction between solitary and sociable testing approaches. See Solitary API.

  • New .sociable() method: Added to the TestBed API for testing with real implementations of select dependencies. See Sociable API.

  • Unified TestBed import: TestBed is now exported from @suites/unit regardless of the installed adapters. Instead of importing from @automock/jest or @automock/sinon, now import from @suites/unit.

  • Mocked type: The new Mocked<T> type from @suites/unit provides deep partial mock capabilities, allowing for deep mocks of properties within the class.

API Changes in TestBed:

  • .mock.using is now .mock.impl and .mock.final.
  • .mock.impl provides runtime stubs within the callback, eliminating the need for library-specific mock functions like jest.fn() or vi.fn().
  • .mock.final is similar but without stubs and cannot be retrieved from the unit reference.

See Mock Configuration API for complete details.

New Features

  • Support for Vitest and ESM: Suites now supports Vitest and ECMAScript Modules (ESM).
  • Sociable Unit Testing: Test with real implementations of selected dependencies. See Sociable Unit Tests.
  • Enhanced Type Safety: Improved TypeScript support with the Mocked<T> type. See Types API.

Troubleshooting Common Migration Issues

Async/Await Errors

Errors like TypeError: Cannot read properties of undefined (reading 'get') indicate missing await with TestBed.solitary().compile().

Type Errors with Mocked

Import Mocked<T> from @suites/unit and include the adapter’s /unit declaration in your test project. See Type Reference Configuration.

See Types API Reference for details:

// Before
import { UserRepository } from './user.repository';
let userRepo: jest.Mocked<UserRepository>;
// After
import { Mocked } from '@suites/unit';
import { UserRepository } from './user.repository';
let userRepo: Mocked<UserRepository>;

Missing Dependencies

Errors about missing dependencies indicate that adapter packages need installation.

See Installation Guide for the complete list of adapters.

Looking for old Automock internals?

If you were depending on Automock internals rather than the public TestBed API, some symbols and file paths have moved or been renamed in Suites. The most common ones people search for:

AutomockSuites
@automock/jest@suites/unit plus @suites/doubles.jest
@automock/sinonMigrate to @suites/unit with the Jest or Vitest adapter; Sinon has no v4 adapter
@automock/core@suites/core.unit (internal; consume the public API via @suites/unit)
TestBed.create(Service)TestBed.solitary(Service) (now async)
.mock(X).using({...}).mock(X).final({...}) or .mock(X).impl((stub) => ({...}))
packages/core/src/services/testbed-builder.tsRestructured under @suites/core.unit and the DI adapters
TestbedBuilder (internal class)Split into solitary and sociable builders, kept internal
ClassCtorReflector, class-props-reflectorReflection utilities now live inside @suites/di.nestjs and @suites/di.inversify and are not part of the public API

Recommended path: depend only on the public surface (TestBed from @suites/unit and the Mocked<T> type). If you have a use case that requires internals, please open an issue so we can either expose what you need or suggest an alternative.

Historical Releases and NPM Packages

The release history and NPM packages under the @automock scope remain available for historical reference and existing projects. All new features and improvements are released under the @suites scope.

For more information, see the Suites release notes.

Next Steps

  • Quick Start: Choose your framework and verify the migrated setup with a complete test.
  • Installation: Check adapter declarations and runner configuration.