Page Contents

Home > @loopback/testlab > createStubInstance

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 - -


export declare function createStubInstance<TType>(constructor: sinon.StubbableType<TType>): StubbedInstanceWithSinonAccessor<TType>;


Parameter Type Description
constructor sinon.StubbableType<TType> Object or class to stub.



A stubbed version of the constructor, with an extra property stubs providing access to stub API for individual methods.