Skip to content

Commit 71c1e93

Browse files
authored
fix(@jest/globals): add missing options argument to jest.doMock typing (#12292)
1 parent 60a788e commit 71c1e93

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
### Fixes
66

7-
- `[matcher-utils]` Correct diff for expected asymmetric matchers ([#12264](https://github.com/facebook/jest/pull/12264))
87
- `[expect]` Add a fix for `.toHaveProperty('')` ([#12251](https://github.com/facebook/jest/pull/12251))
8+
- `[@jest/globals]` Add missing `options` argument to `jest.doMock` typing ([#12292](https://github.com/facebook/jest/pull/12292))
99
- `[jest-environment-node]` Add `atob` and `btoa` ([#12269](https://github.com/facebook/jest/pull/12269))
10+
- `[jest-matcher-utils]` Correct diff for expected asymmetric matchers ([#12264](https://github.com/facebook/jest/pull/12264))
1011
- `[jest-message-util]` Fix `.getTopFrame()` (and `toMatchInlineSnapshot()`) with `mjs` files ([#12277](https://github.com/facebook/jest/pull/12277))
1112

1213
### Chore & Maintenance

packages/jest-environment/src/index.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ export interface Jest {
9292
* the top of the code block. Use this method if you want to explicitly avoid
9393
* this behavior.
9494
*/
95-
doMock(moduleName: string, moduleFactory?: () => unknown): Jest;
95+
doMock(
96+
moduleName: string,
97+
moduleFactory?: () => unknown,
98+
options?: {virtual?: boolean},
99+
): Jest;
96100
/**
97101
* Indicates that the module system should never return a mocked version
98102
* of the specified module from require() (e.g. that it should always return

packages/jest-types/__typechecks__/jest.test.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ expectType<typeof jest>(jest.deepUnmock('moduleName'));
2020
expectType<typeof jest>(jest.disableAutomock());
2121
expectType<typeof jest>(jest.doMock('moduleName'));
2222
expectType<typeof jest>(jest.doMock('moduleName', jest.fn()));
23-
24-
expectError(jest.doMock('moduleName', jest.fn(), {}));
25-
expectError(jest.doMock('moduleName', jest.fn(), {virtual: true}));
23+
expectType<typeof jest>(jest.doMock('moduleName', jest.fn(), {}));
24+
expectType<typeof jest>(jest.doMock('moduleName', jest.fn(), {virtual: true}));
2625

2726
expectType<typeof jest>(jest.dontMock('moduleName'));
2827
expectType<typeof jest>(jest.enableAutomock());

0 commit comments

Comments
 (0)