DefinitelyTyped/types/heft-jest/index.d.ts
Pete Gonzalez 2e00c0081a
🤖 Merge PR #47093 Add richer types for @types/heft-jest by @octogonz
* prettier . --write

* Add mocked.d.ts typings

* Add doc comment

* Add more test cases
2020-08-27 21:28:11 -04:00

37 lines
1.3 KiB
TypeScript

// Type definitions for heft-jest 1.0
// Project: https://github.com/octogonz/heft-jest
// Definitions by: Pete Gonzalez <https://github.com/octogonz>
// Ian Clanton-Thuon <https://github.com/iclanton>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.5
/// <reference types="jest" />
/// <reference path="./mocked.d.ts" />
/**
* Tests can use the `mocked()` function to access additional properties that
* Jest adds to a mocked object.
*
* @remarks
*
* In the example below, `mockClear()` is not part of the type signature for the
* real `SoundPlayer` class. It is added by Jest. The `mocked()` function returns
* its input object but extends the type signature with these additional members.
*
* ```ts
* jest.mock('./SoundPlayer');
* import SoundPlayer from './SoundPlayer';
*
* // mockClear() is provided by Jest's API:
* mocked(SoundPlayer).mockClear();
* ```
*
* Heft's API is based on `mocked()` from `ts-jest`, but provided as a global API
* so you don't need to explicitly import it. For more information, see the `ts-jest`
* documentation here:
*
* https://kulshekhar.github.io/ts-jest/user/test-helpers
*/
declare function mocked<T>(item: T, deep?: false): mocked.MaybeMocked<T>;
declare function mocked<T>(item: T, deep: true): mocked.MaybeMockedDeep<T>;