From bed60d03c4a60e4eeba0583aefb988c8495d446f Mon Sep 17 00:00:00 2001 From: mrazauskas <72159681+mrazauskas@users.noreply.github.com> Date: Wed, 2 Feb 2022 15:26:43 +0200 Subject: [PATCH 1/2] fix: doMock types --- packages/jest-environment/src/index.ts | 6 +++++- packages/jest-types/__typechecks__/jest.test.ts | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/jest-environment/src/index.ts b/packages/jest-environment/src/index.ts index b5920f7d00e9..509a4dac4fad 100644 --- a/packages/jest-environment/src/index.ts +++ b/packages/jest-environment/src/index.ts @@ -92,7 +92,11 @@ export interface Jest { * the top of the code block. Use this method if you want to explicitly avoid * this behavior. */ - doMock(moduleName: string, moduleFactory?: () => unknown): Jest; + doMock( + moduleName: string, + moduleFactory?: () => unknown, + options?: {virtual?: boolean}, + ): Jest; /** * Indicates that the module system should never return a mocked version * of the specified module from require() (e.g. that it should always return diff --git a/packages/jest-types/__typechecks__/jest.test.ts b/packages/jest-types/__typechecks__/jest.test.ts index 1c0a5483ca56..a1d60669698f 100644 --- a/packages/jest-types/__typechecks__/jest.test.ts +++ b/packages/jest-types/__typechecks__/jest.test.ts @@ -20,9 +20,8 @@ expectType(jest.deepUnmock('moduleName')); expectType(jest.disableAutomock()); expectType(jest.doMock('moduleName')); expectType(jest.doMock('moduleName', jest.fn())); - -expectError(jest.doMock('moduleName', jest.fn(), {})); -expectError(jest.doMock('moduleName', jest.fn(), {virtual: true})); +expectType(jest.doMock('moduleName', jest.fn(), {})); +expectType(jest.doMock('moduleName', jest.fn(), {virtual: true})); expectType(jest.dontMock('moduleName')); expectType(jest.enableAutomock()); From b2ebf3424bed49706c074f0737ced42d229ad240 Mon Sep 17 00:00:00 2001 From: mrazauskas <72159681+mrazauskas@users.noreply.github.com> Date: Wed, 2 Feb 2022 15:36:01 +0200 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51e4ba29c4c8..be44ac509e8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,10 @@ ### Fixes -- `[matcher-utils]` Correct diff for expected asymmetric matchers (#12264)[https://github.com/facebook/jest/pull/12264] - `[expect]` Add a fix for `.toHaveProperty('')` ([#12251](https://github.com/facebook/jest/pull/12251)) +- `[@jest/globals]` Add missing `options` argument to `jest.doMock` typing ([#12292](https://github.com/facebook/jest/pull/12292)) - `[jest-environment-node]` Add `atob` and `btoa` ([#12269](https://github.com/facebook/jest/pull/12269)) +- `[matcher-utils]` Correct diff for expected asymmetric matchers (#12264)[https://github.com/facebook/jest/pull/12264] ### Chore & Maintenance