1.4.1 • Published 2 months ago

ts-jest-mock v1.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Format code Release Test code Mutation testing badge Commitizen friendly semantic-release npm npm npm bundle size (minified) All Contributors

forthebadge forthebadge

ts-jest-mock

A way to get jest type definition infered automagically.

Pre-requisites

This library takes for granted that you have your tests setup with jest.

Usage

Directly in a test

import { createMock } from 'ts-jest-mock'
import { someFn } from 'module_a'

jest.mock('module_a')

describe('something', () => {
  it('some test', () => {
    const someFnMock = createMock(someFn)

    someFnMock.mockReturnValue('') <-- Type inference yay :)
  })
})

Or with a beforeEach pattern

import { createMock } from 'ts-jest-mock'
import { someFn } from 'module_a'

jest.mock('module_a')

const someFnMock = createMock(someFn)

describe('something', () => {
  beforeEach(() => {
    someFnMock.mockReturnValue('') <-- Type inference yay :)
  })

  it('some test', () => {
    expect(someFnMock).toBe('')
  })
})

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

1.4.1

2 months ago

1.4.0

3 months ago

1.3.0

11 months ago

1.2.0

1 year ago

1.2.1

1 year ago

1.1.33

2 years ago

1.1.32

2 years ago

1.1.1

2 years ago

1.1.29

2 years ago

1.1.28

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.30

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.31

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.1.17

2 years ago

1.1.23

2 years ago

1.1.22

2 years ago

1.1.21

2 years ago

1.1.20

2 years ago

1.1.27

2 years ago

1.1.26

2 years ago

1.1.25

2 years ago

1.1.24

2 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago