Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/sinon

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/sinon

TypeScript definitions for sinon

  • 17.0.3
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3M
increased by0.35%
Maintainers
1
Weekly downloads
 
Created

What is @types/sinon?

The @types/sinon package provides TypeScript type definitions for Sinon.js, a standalone test spies, stubs, and mocks for JavaScript. It enables developers using TypeScript to get compile-time type checking and IntelliSense support when working with Sinon.js, ensuring that they use the Sinon.js API correctly.

What are @types/sinon's main functionalities?

Spies

Spies are functions that record arguments, return value, the value of this, and exception thrown (if any) for all its calls. Useful for testing your functions are called correctly.

const spy = sinon.spy();
spy('Hello', 'World');
console.log(spy.firstCall.args); // Logs: ['Hello', 'World']

Stubs

Stubs are like spies, but they can replace the target function. They can be used to control a method's behavior without affecting the rest of your code's execution.

const stub = sinon.stub().returns('Hello World');
console.log(stub()); // Logs: 'Hello World'

Mocks

Mocks combine spies and stubs. They are fake methods (like stubs) with pre-programmed behavior (like spies) as well as pre-programmed expectations. A mock will fail your test if it is not used as expected.

const myAPI = { method: function () {} };
const mock = sinon.mock(myAPI);
mock.expects('method').once().returns('Hello World');
myAPI.method(); // Satisfies the expectation
mock.verify();

Other packages similar to @types/sinon

FAQs

Package last updated on 10 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc