ts-import-mocks
v0.0.2
Published
[![Build Status](https://travis-ci.com/maxjoehnk/ts-import-mocks.svg?branch=master)](https://travis-ci.com/maxjoehnk/ts-import-mocks)
Downloads
33
Readme
ts-import-mocks
Generate mocked typescript interfaces with fake data (generated by faker.js).
Does not work in a browser environment (right now).
Very WIP this is a prototype and should not be used in production
Usage
my-interface.ts
export interface MyInterface {
// generates a id unique per generator instance
// #[id]
id: number;
// generates a v4 uuid
// #[uuid]
uuid: string;
// generates a random number
random: number;
}
my-interface.spec.ts
import { importMock } from 'ts-import-mocks';
import { MyInterface } from './my-interface';
const mock = importMock<MyInterface>('./my-interface');
test('', () => {
const data: MyInterface = mock.generate();
// ...
});
Building
Running make
will compile the typescript sources into the lib folder.
Testing
Running make test
will execute all unit and integration tests