ts-jest-mock
Une méthode pour inférer automatiquement les définitions de types Jest.
ts-jest-mock
It is a library to help writing unit tests using jest and TypeScript. With the createMock helper, you will be able to automatically infer the values when using all the .mock functions when using mocks.
For example, let’s say myAwesomeThing is a function that returns a number.
import { myAwesomeThing } from 'my-awesome-module'
import { createMock } from 'ts-jest-mock'
jest.mock('my-awesome-module')
const myAwesomeThingMock = createMock(myAwesomeThing)
describe('some describe', () => {
it('test something', () => {
myAwesomeThingMock.mockReturnValue(4)
expect(myAwesomeThing()).toBe(4)
})
})