3.0.0 • Published 9 months ago

@datx/test-data-factory v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@datx/test-data-factory

Rather than instancing random models each time you want to test something in your system you can instead use a factory that can create fake data. This keeps your tests consistent and means that they always use data that replicates the real thing. If your tests work off objects close to the real thing they are more useful and there's a higher chance of them finding bugs.

npm install --save-dev @datx/test-data-factory
yarn add --dev @datx/test-data-factory

Basic usage

We use the build function to create a factory. You give a factory an object of fields you want to define:

import { createFactory } from '@datx/test-data-factory';
import { createClient } from './create-client';
import { User } from './models/User';

const client = createClient();
const factory = createFactory(client);

const userFactory = factory(User, {
  fields: {
    name: 'John',
  },
});

const user = userFactory();

console.log(user); // => { name: 'John'}

Docs

Inspired by

Troubleshooting

Having issues with the library? Check out the troubleshooting page or open an issue.


Build Status

License

The MIT License

Credits

datx is maintained and sponsored by Infinum.

3.0.0-beta.1

10 months ago

3.0.0-beta.2

10 months ago

3.0.0

10 months ago

2.6.2-beta.2

9 months ago

2.5.1-beta.1

1 year ago

2.6.1

11 months ago

2.5.1

1 year ago

1.0.0-9

1 year ago

1.0.0-8

1 year ago

2.4.0-1

1 year ago

1.0.0-7

1 year ago

1.0.0-6

1 year ago

1.0.0-5

1 year ago

1.0.0-4

1 year ago

1.0.0-3

1 year ago

1.0.0-2

1 year ago

1.0.0-1

1 year ago