Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-ts-mock

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-ts-mock

Type safe mocking for jest

  • 1.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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

});

FAQs

Package last updated on 15 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc