UNPKG

@loopback/docs

Version:

Documentation files rendered at [https://loopback.io](https://loopback.io)

71 lines (37 loc) 1.92 kB
--- lang: en title: 'API docs: testlab.createstubinstance' keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI sidebar: lb4_sidebar editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/testlab permalink: /doc/en/lb4/apidocs.testlab.createstubinstance.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/testlab](./testlab.md) &gt; [createStubInstance](./testlab.createstubinstance.md) ## createStubInstance() function Creates a new object with the given functions as the prototype and stubs all implemented functions. Note: The given constructor function is not invoked. See also the stub API. This is a helper method replacing `sinon.createStubInstance` and working around the limitations of TypeScript and Sinon, where Sinon is not able to list private/protected members in the type definition of the stub instance and therefore the stub instance cannot be assigned to places expecting TType. See also - https://github.com/Microsoft/TypeScript/issues/13543 - https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14811 **Signature:** ```typescript export declare function createStubInstance<TType extends object>(constructor: sinon.StubbableType<TType>): StubbedInstanceWithSinonAccessor<TType>; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td markdown="1"> constructor </td><td markdown="1"> sinon.StubbableType&lt;TType&gt; </td><td markdown="1"> Object or class to stub. </td></tr> </tbody></table> **Returns:** [StubbedInstanceWithSinonAccessor](./testlab.stubbedinstancewithsinonaccessor.md)<!-- -->&lt;TType&gt; A stubbed version of the constructor, with an extra property `stubs` providing access to stub API for individual methods.