0.1.9 • Published 4 years ago

mock-my-ride v0.1.9

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

mock-my-ride

Creates an object copy wiith all functions returns as a jest.mock that returns the origina, implementation Also creates a function to mock the return value of an imported function

Installation

npm install mock-my-ride

Usage example

import { mockFunctions, setMockValue } from 'mock-my-ride';

mockFunctions(require('./sub-func'));
import isStringSub, { isNumberSub } from './sub-func';

// Functions under test
import isString, { isNumber } from './index';

describe('isString', () => {
  it('return true when isStringSub is true', () => {
    setMockValue(isStringSub, true);

    expect(isString()).toEqual(true);
  });
});

describe('isNumber', () => {
  it('return true when isNumberSub is true', () => {
    setMockValue(isNumberSub, true);

    expect(isNumber()).toEqual(true);
  });
});
0.1.8

4 years ago

0.1.9

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago