@websolute/faker.ts
Version:
Easy to Use, Powered by Decorators, Faker.js TypeScript Wrapper
32 lines (31 loc) • 1.21 kB
TypeScript
import { ClassLiteral, Class } from '../types/fixture-options.type';
import { FixtureFactoryOptions } from '../types';
export declare class FixtureFactory {
/**
* Return an object with all the properties decorated by the 'Fixture' Decorator
*
* @example
* class Person { @Fixture() name: string }
* FixtureFactory.create(Person) will return an object { name: <random-string> }
*
* @param target
*/
static create<T = unknown>(target: Class<T>): ClassLiteral<T>;
/**
* Return an array of objects with all the properties decorated by the
* 'Fixture' Decorator (if 'count' is greater than 1)
*
* @example
* class Person { @Fixture() name: string }
* FixtureFactory.create(Person, { count: 3, locale: 'es' }) will return an
* array of objects [{ name: <random-string> }, { name: <random-string> },
* { name: <random-string> }]
*
* Passing a 'locale' property will set a different locale for faker calls
* The default locale is 'en' (english)
*
* @param target
* @param options
*/
static create<T = unknown>(target: Class<T>, options: FixtureFactoryOptions): ClassLiteral<T>[];
}