1 | import sinon, { SinonSpy } from 'sinon';
|
2 | export { sinon, SinonSpy };
|
3 | export type StubbedInstanceWithSinonAccessor<T> = T & {
|
4 | stubs: sinon.SinonStubbedInstance<T>;
|
5 | };
|
6 | /**
|
7 | * Creates a new object with the given functions as the prototype and stubs all
|
8 | * implemented functions.
|
9 | *
|
10 | * Note: The given constructor function is not invoked. See also the stub API.
|
11 | *
|
12 | * This is a helper method replacing `sinon.createStubInstance` and working
|
13 | * around the limitations of TypeScript and Sinon, where Sinon is not able to
|
14 | * list private/protected members in the type definition of the stub instance
|
15 | * and therefore the stub instance cannot be assigned to places expecting TType.
|
16 | * See also
|
17 | * - https://github.com/Microsoft/TypeScript/issues/13543
|
18 | * - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14811
|
19 | *
|
20 | * @typeParam TType - Type being stubbed.
|
21 | * @param constructor - Object or class to stub.
|
22 | * @returns A stubbed version of the constructor, with an extra property `stubs`
|
23 | * providing access to stub API for individual methods.
|
24 | */
|
25 | export declare function createStubInstance<TType extends object>(constructor: sinon.StubbableType<TType>): StubbedInstanceWithSinonAccessor<TType>;
|