Made function argument to mockImplementation optional (#27599)

This commit is contained in:
Bernie Sumption
2018-07-26 19:57:40 +01:00
committed by Andy
parent 73541f5feb
commit 712a47b529
2 changed files with 2 additions and 1 deletions

View File

@@ -775,7 +775,7 @@ declare namespace jest {
*
* Note: `jest.fn(implementation)` is a shorthand for `jest.fn().mockImplementation(implementation)`.
*/
mockImplementation(fn: (...args: any[]) => any): Mock<T>;
mockImplementation(fn?: (...args: any[]) => any): Mock<T>;
/**
* Accepts a function that will be used as an implementation of the mock for one call to the mocked function.
* Can be chained so that multiple function calls produce different results.

View File

@@ -298,6 +298,7 @@ spy2.mockReset();
const spy3Mock: jest.Mock<() => string> = spy3
.mockImplementation(() => "")
.mockImplementation()
.mockImplementation((arg: {}) => arg)
.mockImplementation((...args: string[]) => args.join(""))
.mockImplementationOnce(() => "")