diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 090b87d0b5..0ba1762485 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -533,6 +533,8 @@ declare namespace jest { mockReturnThis(): Mock; mockReturnValue(value: any): Mock; mockReturnValueOnce(value: any): Mock; + mockName(name: string): Mock; + getMockName(): string; } interface MockContext { diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index aca5021f1b..88f72f3f1a 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -311,7 +311,7 @@ describe('missing tests', () => { expect(jest.isMockFunction(spy)).toBeTruthy(); }); - it('tests all mising Mocks functionality', () => { + it('tests all missing Mocks functionality', () => { type FruitsGetter = () => string[]; const mock: jest.Mock = jest.fn(); mock.mockImplementationOnce(() => ['Orange', 'Apple', 'Plum']); @@ -328,6 +328,12 @@ describe('missing tests', () => { expect(thisMock()).toBe(this); }); + it('tests mock name functionality', () => { + const mock: jest.Mock = jest.fn(); + mock.mockName('Carrot'); + expect(mock.getMockName()).toBe('Carrot'); + }); + it('creates snapshoter', () => { jest.disableAutomock().mock('./render', () => jest.fn((): string => "{Link to: \"facebook\"}"), { virtual: true }); const render: () => string = require('./render');