efate-faker
TypeScript icon, indicating that this package has built-in type declarations

1.5.1 • Public • Published

efate-faker

Use the faker library to populate property values

Usage

Install the extension and pass the interface and function to createFixtureFactory

import { createFixtureFactory } from 'efate';
import { FakerExtension, fakerExtension } from 'efate-faker';
const createFixture = createFixtureFactory<FakerExtension>(fakerExtension);

This exposes a faker() function that accepts a function as parameter to specify which faker methods you want to use. The incremement value is also passed to the callback function if you want to use it.

interface User {
  firstName: string;
  userName: string;
}
const userFixture = createFixture<User>((t) => {
  t.firstName.faker((faker, increment) => faker.name.firstName());
  t.userName.faker((faker, increment) => faker.internet.userName());
});

Todo

This is the first pass at the this extension and really was the quickest way to implement it. It would be nice not to have to relay on the callback function. Also, currently the Faker object doesn't accept the option parameters, so its behavior can't be modified yet.

Readme

Keywords

Package Sidebar

Install

npm i efate-faker

Weekly Downloads

69

Version

1.5.1

License

MIT

Unpacked Size

15.7 kB

Total Files

13

Last publish

Collaborators

  • jcteague