jest-ts-mock

1.0.3 • Public • Published

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');
   });
 
});

Readme

Keywords

none

Package Sidebar

Install

npm i jest-ts-mock

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

4.88 kB

Total Files

7

Last publish

Collaborators

  • marchaos