Skip to content

Commit

Permalink
fix(@jest/globals): add missing options argument to jest.doMock t…
Browse files Browse the repository at this point in the history
…yping (#12292)
  • Loading branch information
mrazauskas committed Feb 3, 2022
1 parent 60a788e commit 71c1e93
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -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))
- `[jest-matcher-utils]` Correct diff for expected asymmetric matchers ([#12264](https://github.com/facebook/jest/pull/12264))
- `[jest-message-util]` Fix `.getTopFrame()` (and `toMatchInlineSnapshot()`) with `mjs` files ([#12277](https://github.com/facebook/jest/pull/12277))

### Chore & Maintenance
Expand Down
6 changes: 5 additions & 1 deletion packages/jest-environment/src/index.ts
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions packages/jest-types/__typechecks__/jest.test.ts
Expand Up @@ -20,9 +20,8 @@ expectType<typeof jest>(jest.deepUnmock('moduleName'));
expectType<typeof jest>(jest.disableAutomock());
expectType<typeof jest>(jest.doMock('moduleName'));
expectType<typeof jest>(jest.doMock('moduleName', jest.fn()));

expectError(jest.doMock('moduleName', jest.fn(), {}));
expectError(jest.doMock('moduleName', jest.fn(), {virtual: true}));
expectType<typeof jest>(jest.doMock('moduleName', jest.fn(), {}));
expectType<typeof jest>(jest.doMock('moduleName', jest.fn(), {virtual: true}));

expectType<typeof jest>(jest.dontMock('moduleName'));
expectType<typeof jest>(jest.enableAutomock());
Expand Down

0 comments on commit 71c1e93

Please sign in to comment.