TS auto mock
HomeInstallationCreate mockCreate mock listProperty overridesCreate hydrated mockRegister mockExtensionTypes supportedTypes not supportedConfigPerformanceDefinitely TypedLocal development

Create mock list

createMockList creates an array of mocks, so you don't have to do that tedious part yourself.

import { createMockList } from 'ts-auto-mock';
interface Person {
id: string;
}
const mockList = createMockList<Person>(2);
mockList.length // 2

Property overrides

You can supply a function as the second argument to override specific properties.

The function will be supplied the index of the individual element as the callback argument, e.g.:

import { createMockList } from 'ts-auto-mock';
interface Person {
id: string;
}
const mockList = createMockList<Person>(2, (index: number) => {
return {
id: "id" + index
};
});
mockList[0].id // id0
mockList[1].id // id1