In-memory storage
InMemoryStorage is the default backend. It keeps all resources in plain
JavaScript data structures in the current process.
import { CommercetoolsMock, InMemoryStorage } from '@labdigital/commercetools-mock'
const ctMock = new CommercetoolsMock({ defaultProjectKey: 'my-project', storage: new InMemoryStorage(), // optional — this is the default})Characteristics
Section titled “Characteristics”- Fast — no I/O, everything is in RAM.
- Isolated — state lives in the process and disappears when it exits.
- Reset with
clear()— callctMock.clear()(typically inafterEach) to wipe all data between tests.
When to use
Section titled “When to use”This is the right choice for essentially all testing. Reach for SQLite only if you specifically need persistence or want to work with larger datasets in the standalone server.
Clearing between tests
Section titled “Clearing between tests”afterEach(async () => { mswServer.resetHandlers() await ctMock.clear()})clear() is async — always await it.