1.0.3 • Published 4 years ago

jest-ts-mock v1.0.3

Weekly downloads
12
License
MIT
Repository
-
Last release
4 years ago

jest-ts-mock

Type safe mocking framework for Jest

Installation

npm install jest-ts-mock --save-dev

or

yarn add jest-ts-mock --dev

Example

import mock from 'jest-ts-mock';

interface FunProvider {
   getSomeFun: () => string;
   makeFun: (funMethod: string) => void;
}

describe('My Awesome Tests', () => {

   test('Mock out an interface', () => {
       const mock = mock<FunProvider>();
       mock.makeFun('disco party');
       
       expect(mock.makeFun).toHaveBeenCalledWith('disco party');
   });
   
   
   test('mock out a return type', () => {
       const mock = mock<FunProvider>();
       mock.getSomeFun.mockReturnValue('west coast party');
       
       expect(mock.getSomeFun()).toBe('west coast party');
   });

});
1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago