Skip to content
This repository has been archived by the owner on May 14, 2020. It is now read-only.
/ typefixture Public archive

Inspired by AutoFixture but written with TypeScript for TypeScript developers.

Notifications You must be signed in to change notification settings

mtebenev/typefixture

Repository files navigation

Overview

This library is inspired by AutoFixture but written with TypeScript for TypeScript developers.

TL;DR

import {Fixture} from '@typefixture/core';
interface ITestInterface {
  a: number;
  b: string;
}
describe('Jest simple tests', () => {
  it('Should create an object with interface', () => {
    const fixture = new Fixture();
    const generated = fixture.create<ITestInterface>();
    expect(generated.a).toEqual(expect.any(Number));
    expect(generated.b).toEqual(expect.any(String));
  });
});

Using with Jest (ts-jest)

npm install @typefixture/core --save-dev
npm install @typefixture/jest --save-dev
npm install ts-morph --save-dev

In jest.config.js

...
globals: {
  'ts-jest': {
    astTransformers: [
      '@typefixture/jest'
    ]
  }
}
...

Word of caution

  • This library is in PoC state.
  • ts-morph dependency to be removed.

Known issues

  • Use --no-cache jest CLI option (i.e. npx jest --no-cache)

About

Inspired by AutoFixture but written with TypeScript for TypeScript developers.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published