File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed
Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -1031,7 +1031,7 @@ declare module "node:test" {
10311031 * @since v19.1.0, v18.13.0
10321032 * @param implementation The function to be used as the mock's new implementation.
10331033 */
1034- mockImplementation ( implementation : Function ) : void ;
1034+ mockImplementation ( implementation : F ) : void ;
10351035 /**
10361036 * This function is used to change the behavior of an existing mock for a single
10371037 * invocation. Once invocation `onCall` has occurred, the mock will revert to
@@ -1068,7 +1068,7 @@ declare module "node:test" {
10681068 * @param implementation The function to be used as the mock's implementation for the invocation number specified by `onCall`.
10691069 * @param onCall The invocation number that will use `implementation`. If the specified invocation has already occurred then an exception is thrown.
10701070 */
1071- mockImplementationOnce ( implementation : Function , onCall ?: number ) : void ;
1071+ mockImplementationOnce ( implementation : F , onCall ?: number ) : void ;
10721072 /**
10731073 * Resets the call history of the mock function.
10741074 * @since v19.3.0, v18.13.0
Original file line number Diff line number Diff line change @@ -772,6 +772,12 @@ class TestReporter extends Transform {
772772 }
773773}
774774const createdMock : Mock < ( ) => undefined > = mock . fn ( ( ) => undefined ) ;
775+ // @ts -expect-error
776+ createdMock . mock . mockImplementation ( ( ) => null ) ;
777+ createdMock . mock . mockImplementation ( ( ) => undefined ) ;
778+ // @ts -expect-error
779+ createdMock . mock . mockImplementationOnce ( ( ) => null ) ;
780+ createdMock . mock . mockImplementationOnce ( ( ) => undefined ) ;
775781
776782// Allows for typing of TestContext outside of a test
777783const contextTest = ( t : TestContext ) => {
Original file line number Diff line number Diff line change @@ -729,7 +729,7 @@ declare module "node:test" {
729729 * This function is used to change the behavior of an existing mock.
730730 * @param implementation The function to be used as the mock's new implementation.
731731 */
732- mockImplementation ( implementation : Function ) : void ;
732+ mockImplementation ( implementation : F ) : void ;
733733
734734 /**
735735 * This function is used to change the behavior of an existing mock for a single invocation.
@@ -739,7 +739,7 @@ declare module "node:test" {
739739 * @param onCall The invocation number that will use `implementation`.
740740 * If the specified invocation has already occurred then an exception is thrown.
741741 */
742- mockImplementationOnce ( implementation : Function , onCall ?: number ) : void ;
742+ mockImplementationOnce ( implementation : F , onCall ?: number ) : void ;
743743
744744 /**
745745 * Resets the call history of the mock function.
You can’t perform that action at this time.
0 commit comments