0.0.2 • Published 6 years ago

ts-import-mocks v0.0.2

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
6 years ago

ts-import-mocks

Build Status

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