Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions types/node/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ declare module "node:test" {
* @since v19.1.0, v18.13.0
* @param implementation The function to be used as the mock's new implementation.
*/
mockImplementation(implementation: Function): void;
mockImplementation(implementation: F): void;
/**
* This function is used to change the behavior of an existing mock for a single
* invocation. Once invocation `onCall` has occurred, the mock will revert to
Expand Down Expand Up @@ -1068,7 +1068,7 @@ declare module "node:test" {
* @param implementation The function to be used as the mock's implementation for the invocation number specified by `onCall`.
* @param onCall The invocation number that will use `implementation`. If the specified invocation has already occurred then an exception is thrown.
*/
mockImplementationOnce(implementation: Function, onCall?: number): void;
mockImplementationOnce(implementation: F, onCall?: number): void;
/**
* Resets the call history of the mock function.
* @since v19.3.0, v18.13.0
Expand Down
6 changes: 6 additions & 0 deletions types/node/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,12 @@ class TestReporter extends Transform {
}
}
const createdMock: Mock<() => undefined> = mock.fn(() => undefined);
// @ts-expect-error
createdMock.mock.mockImplementation(() => null);
createdMock.mock.mockImplementation(() => undefined);
// @ts-expect-error
createdMock.mock.mockImplementationOnce(() => null);
createdMock.mock.mockImplementationOnce(() => undefined);

// Allows for typing of TestContext outside of a test
const contextTest = (t: TestContext) => {
Expand Down
4 changes: 2 additions & 2 deletions types/node/v18/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ declare module "node:test" {
* This function is used to change the behavior of an existing mock.
* @param implementation The function to be used as the mock's new implementation.
*/
mockImplementation(implementation: Function): void;
mockImplementation(implementation: F): void;

/**
* This function is used to change the behavior of an existing mock for a single invocation.
Expand All @@ -739,7 +739,7 @@ declare module "node:test" {
* @param onCall The invocation number that will use `implementation`.
* If the specified invocation has already occurred then an exception is thrown.
*/
mockImplementationOnce(implementation: Function, onCall?: number): void;
mockImplementationOnce(implementation: F, onCall?: number): void;

/**
* Resets the call history of the mock function.
Expand Down