# node-factory

> Easy way to generate random data for your tests

Latest version **0.4.2** (published 2021-07-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-factory
pnpm add node-factory
yarn add node-factory
bun add node-factory
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.2 |
| Published | 2021-07-19 |
| First published | 2018-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 36.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Olavo Amorim Santos |
| Maintainers | olavo.a.santos |
| Keywords | data factory, testing |

## Links

- npm: https://www.npmjs.com/package/node-factory
- Repository: https://github.com/olavoasantos/node-factory
- Homepage: https://olavoasantos.github.io/node-factory/
- Issues: https://github.com/olavoasantos/node-factory/issues
- npm.io page: https://npm.io/package/node-factory

## Dependencies (2)

- [faker](https://npm.io/package/faker.md) ^5.5.3
- [@types/faker](https://npm.io/package/@types/faker.md) ^5.5.7

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.4.2 (latest) — 2021-07-19
- 0.4.1 — 2020-03-27
- 0.4.0 — 2020-02-18
- 0.3.10 — 2019-12-27
- 0.3.9 — 2019-12-20
- 0.3.8 — 2019-12-20
- 0.3.7 — 2019-12-20
- 0.3.6 — 2019-12-19
- 0.3.5 — 2019-11-17
- 0.3.4 — 2019-11-14
- 0.3.3 — 2019-11-14
- 0.3.2 — 2019-11-14
- 0.3.1 — 2019-11-13
- 0.3.0 — 2019-11-13
- 0.2.6 — 2019-09-10
- … 9 more at https://npm.io/package/node-factory/versions

## README

# Node Factory

![version](https://img.shields.io/npm/v/node-factory.svg)
![issues](https://img.shields.io/github/issues/olavoasantos/node-factory.svg)
![issues](https://img.shields.io/github/issues-pr/olavoasantos/node-factory.svg)

When developing or testing your application, you might need to mock data comming from a database or an endpoint. Instead of manually generating "random" data, you can use model factories.
This package allows you to define a default set of attributes for each of your endpoints or models and easily mock responses.

## Docs

Check out our documentation for APIs and examples at [https://olavoasantos.github.io/node-factory/](https://olavoasantos.github.io/node-factory/)

## Installation

If you're using `yarn`:

```bash
yarn add -D node-factory
```

Or, if you're using `npm`:

```bash
npm install --save-dev node-factory
```

## Usage

```typescript
// 1. Import the factory generator
import { factory } from 'node-factory';

// 2. Create a factory
interface User {
  id: string;
  name: string;
  email: string;
}

const UserFactory = factory<User>(fake => ({
  id: fake.datatype.uuid(),
  name: fake.name.findName(),
  email: fake.internet.email(),
}));

// 3. Generate data
UserFactory.make();
```

## Author

- [Olavo Amorim Santos](https://github.com/olavoasantos)

---
_Source: https://npm.io/package/node-factory · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
