• Version 2.0.2
  • Published
  • 11.2 kB
  • 4 dependencies
  • MIT license


npm i ts-sinon
yarn add ts-sinon
pnpm add ts-sinon


sinon library extension to stub whole object and interfaces



function stubConstructor

stubConstructor: <T extends new (...args: any[]) => any>(
constructor: T,
...constructorArgs: ConstructorParameters<T> | undefined[]
) => StubbedInstance<InstanceType<T>>;

    function stubInterface

    stubInterface: <T extends object>(
    methods?: ObjectMethodsMap<T>
    ) => StubbedInstance<T>;

      function stubObject

      stubObject: <T extends object>(
      object: T,
      methods?: ObjectMethodsKeys<T> | ObjectMethodsMap<T>
      ) => StubbedInstance<T>;

        Type Aliases

        type AllowedKeys

        type AllowedKeys<T, Condition> = {
        [Key in keyof T]: T[Key] extends Condition ? Key : never;
        }[keyof T];

          type ObjectMethodsKeys

          type ObjectMethodsKeys<T> = AllowedKeys<T, (...args: any[]) => any>[];

            type ObjectMethodsMap

            type ObjectMethodsMap<T> = {
            [Key in keyof T]?: T[Key] extends (...args: any[]) => any
            ? ReturnType<T[Key]>
            : never;

              type StubbedInstance

              type StubbedInstance<T> = sinon.SinonStubbedInstance<T> & T;

                Package Files (1)

                Dependencies (4)

                Dev Dependencies (8)

                Peer Dependencies (0)

                No peer dependencies.


                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ts-sinon.

                • Markdown
                • HTML
                  <a href="https://www.jsdocs.io/package/ts-sinon"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>