Skip to content

Commit efbedbb

Browse files
chore: add types for unstable_unmockModule
Closes #15079
1 parent d42d4a3 commit efbedbb

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

packages/jest-environment/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ export interface Jest {
392392
* real module).
393393
*/
394394
unmock(moduleName: string): Jest;
395+
/**
396+
* Indicates that the module system should never return a mocked version of
397+
* the specified module when it is being imported (e.g. that it should always
398+
* return the real module).
399+
*/
400+
unstable_unmockModule(moduleName: string): Jest;
395401
/**
396402
* Instructs Jest to use fake versions of the global date, performance,
397403
* time and timer APIs. Fake timers implementation is backed by

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ expect(
5151
.setMock('moduleName', {a: 'b'})
5252
.setTimeout(6000)
5353
.unmock('moduleName')
54+
.unstable_unmockModule('moduleName')
5455
.useFakeTimers()
5556
.useFakeTimers({legacyFakeTimers: true})
5657
.useRealTimers(),
@@ -183,6 +184,9 @@ expect(jest.setMock('moduleName')).type.toRaiseError();
183184
expect(jest.unmock('moduleName')).type.toEqual<typeof jest>();
184185
expect(jest.unmock()).type.toRaiseError();
185186

187+
expect(jest.unstable_unmockModule('moduleName')).type.toBe<typeof jest>();
188+
expect(jest.unstable_unmockModule()).type.toRaiseError();
189+
186190
// Mock Functions
187191

188192
expect(jest.clearAllMocks()).type.toEqual<typeof jest>();

0 commit comments

Comments
 (0)