Skip to content

ProjectAPI

ProjectAPI is returned by ctMock.project(projectKey?) and scopes operations to a single project. In tests you mostly create and read data through the commercetools API; ProjectAPI offers a couple of convenience methods for reading state directly.

const api = ctMock.project('my-project')
get<RT>(typeId: RT, id: string, params?: GetParams): Promise<ResourceMap[RT]>

Fetches a single resource by id, without going through the SDK. params accepts expand.

const order = await ctMock.project().get('order', orderId, {
expand: ['customer'],
})
getRepository<RT>(typeId: RT): RepositoryMap[RT]

Returns the underlying repository for advanced use. Throws if there is no repository for the type.

Property Type Description
config Config The resolved config (strict flag and storage) for this project.