mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-06 13:11:46 +00:00
fix(jest): add missing arguments for jest.doMock() (#18830)
This commit is contained in:
Vendored
+1
-1
@@ -78,7 +78,7 @@ declare namespace jest {
|
||||
/**
|
||||
* Mocks a module with an auto-mocked version when it is being required.
|
||||
*/
|
||||
function doMock(moduleName: string): typeof jest;
|
||||
function doMock(moduleName: string, factory?: any, options?: MockOptions): typeof 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 the real module).
|
||||
|
||||
@@ -598,3 +598,19 @@ declare const testResult: jest.TestResult;
|
||||
const myTestRunner: jest.TestFramework = () => Promise.resolve(testResult);
|
||||
|
||||
const testResultsProcessor: jest.TestResultsProcessor = result => ({...result, numFailedTests: 1});
|
||||
|
||||
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18826
|
||||
test('moduleName 1', () => {
|
||||
jest.doMock('../moduleName', () => {
|
||||
return jest.fn(() => 1);
|
||||
});
|
||||
const moduleName = require('../moduleName');
|
||||
expect(moduleName()).toEqual(1);
|
||||
});
|
||||
test('moduleName 2', () => {
|
||||
jest.doMock('../moduleName', () => {
|
||||
return jest.fn(() => 2);
|
||||
});
|
||||
const moduleName = require('../moduleName');
|
||||
expect(moduleName()).toEqual(2);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user