# tsfixturefactory

> Easy typescript fixture data

Latest version **1.0.1** (published 2020-07-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install tsfixturefactory
pnpm add tsfixturefactory
yarn add tsfixturefactory
bun add tsfixturefactory
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-07-23 |
| First published | 2020-01-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Brad Morgan |
| Maintainers | bmorganpa |
| Keywords | fixture, typescript, tests, mock |

## Links

- npm: https://www.npmjs.com/package/tsfixturefactory
- Repository: https://github.com/bmorganpa/TsFixtureFactory
- Homepage: https://github.com/bmorganpa/TsFixtureFactory#readme
- Issues: https://github.com/bmorganpa/TsFixtureFactory/issues
- npm.io page: https://npm.io/package/tsfixturefactory

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-07-23
- 1.0.0 — 2020-01-10

## README

# Fixture Factory

This module contains functions for creating fixture factories for typescript
interfaces (with sane defaults) similar to the
[factory_boy](http://factoryboy.readthedocs.io/en/latest/) python library.


## Basic usage

Simply pass a set of default properties to the 'createFixtureFactory' method.
Note that if you do not supply all of the required properties for the interface
that typescript will throw a compiler error.

### Example
    interface Product {
      id: string
      name: string
      other?: number
    }
    const productFactory = createFixtureFactory<Product>({
      id: 'id',
      name: 'my product',
    })

## Using factories inside other factories

You can also supply a factory as a default to another factory to create
nested objects.

### Example
    interface Bar {
      something: string
    }
    interface Foo {
      bar: Bar
    }
    const barFactory = createFixtureFactory<Bar>({
      something: 'my something'
    })
    const fooFactory = createFixtureFactory<Foo>({
      bar: barFactory,
    })

## Using factories to create other factories

You can also supply a factory as the second parameter to 'createFixtureFactory'
to create more specific factories on top of existing factories.

### Example
    interface User {
      name: string
      isAdmin: boolean
    }
    const userFactory = createFixtureFactory<User>({
      name: 'my name',
      isAdmin: false,
    })
    const adminUserFactory = createFixtureFactory<User>({
      isAdmin: true,
    }, userFactory)

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