Software Alternatives, Accelerators & Startups

Sinon.JS

Standalone test spies, stubs and mocks for JavaScript.

Sinon.JS

Sinon.JS Reviews and Details

This page is designed to help you find out whether Sinon.JS is good and if it is the right choice for you.

Screenshots and images

  • Sinon.JS Landing page
    Landing page //
    2023-10-09

Features & Specs

  1. Comprehensive Feature Set

    Sinon.JS offers a wide array of features such as spies, mocks, stubs, and fake timers, which are essential for thorough testing, especially when dealing with asynchronous code and external dependencies.

  2. Standalone

    It is framework-agnostic and does not require any other libraries, allowing it to be easily integrated with any test framework or used in standalone projects.

  3. Extensive Documentation

    Sinon.JS provides well-written and comprehensive documentation, making it easier for developers to understand and effectively use the library's wide range of features.

  4. Community Support

    Sinon.JS has a strong community and is widely adopted, which means that developers can find numerous tutorials, guides, and community discussions to help them solve issues.

  5. Easy Integration with Popular Frameworks

    It easily integrates with popular testing frameworks like Mocha, Jasmine, and QUnit, enhancing the testing capabilities of these frameworks.

Badges

Promote Sinon.JS. You can add any of these badges on your website.

SaaSHub badge
Show embed code

Videos

Sinon.js Tutorial - How to Use Sinon.js, the Mocking Library for Testing

JS.everywhere(2012): Unit Testing Your JS w QUnit and Sinon.JS - Nicholas Silva

Stubbing Javascript date objects using Sinon.js - Stream Highlight

Social recommendations and mentions

We have tracked the following product recommendations or mentions on various public social media platforms and blogs. They can help you see what people think about Sinon.JS and what they use it for.
  • How to get 100% code coverage? ✅
    Now, we need to figure out how to test in general. To begin with, we will use Mocha, Sinon, and to generate C8 reports:. - Source: dev.to / 2 months ago
  • Best Testing Practices in Node.js
    Libraries like Sinon.JS provide robust support for stubs and spies, enabling precise control and inspection of your code's interactions. By favoring stubs and spies, you can keep your tests concise, easier to understand, and less prone to errors. - Source: dev.to / 7 months ago
  • An Introduction to Unit Testing in Node.js
    Mocha is a simple and flexible JavaScript testing framework for browser and Node.js applications. Unlike other testing frameworks, it takes a minimalist approach and relies on external libraries for key tasks. It uses Sinon for handling spies, stubs, and mocks, and Chai as the assertion engine. Mocha is extensible through many plugins and can integrate with most test runners. - Source: dev.to / 9 months ago
  • Writing an Obsidian Plugin Driven By Tests
    As Obsidian code is not available; we must provide some alternate implementation. If you're familiar with sinon, you might think we can create a stubbed instance like this:. - Source: dev.to / 12 months ago
  • Unit Testing in Node.js and TypeScript: A Comprehensive Guide with Jest Integration
    If you are using a mocking library, such as sinon, jest-mock, or ts-mockito, make sure that it is compatible with Jest. You may need to install additional packages or configure them in your configuration file. For example, to use sinon with Jest, you can install the sinon-jest package and add the following to your configuration file:. - Source: dev.to / about 1 year ago
  • Express API Testing
    Mocha is a test runner, Chai is an assertion library, Sinon is a mocking library, this normally the combination you would need to use if you choose mocha, but there are others. Source: about 2 years ago
  • Alternative to AWS Mock
    Instead, use pure functions + dependency inject your stubs (e.g. Parameter to function). Also note, no need for Sinon or some other test double library. JavaScript is so good nowadays to easily make objects/classes/functions or any combination thereof on the fly that are terse. - Source: dev.to / over 2 years ago
  • Unit testing: What to use, and how?
    I've had some good experiences with Ava + Sinon. I've personally disliked Jest because it seemed to do some weird trickery in the background that prevented me from using ES modules. Source: over 2 years ago
  • Can AI help me write tests on legacy code?
    🤖 You can use the Mocha testing framework with the Chai assertion library to write tests for your Express controller. You can also use the Sinon library to mock the database calls. This will allow you to test the controller without actually making a call to the database. You can also use the SuperTest library to make HTTP requests to the controller and test the response. - Source: dev.to / over 2 years ago
  • Need help writing a jest test that mocks an API call which will update state
    You can use sinon js to create a mock version of your http library (axios) that responds with the data you’re expecting. Source: over 2 years ago
  • Unit testing with React and Cypress
    Assertions are the checkpoints of our test block that confirm if an automated test has passed or failed. Cypress bundles the Chai, jQuery, and Sinon.JS libraries for assertions. They check the desired, expected application in which the test is running. A complete listing of assertions can be found in the documentation here. - Source: dev.to / over 2 years ago
  • When to use DI?
    ES module is basically a "class" that you inject dependencies into through imports. And for tests you just use something like sinon to swap module dependencies for mocks. Source: over 2 years ago
  • How to test a function that uses moment to format a date ? usimg karma
    You can use a tool like sinon to pass in your own function instead of the real moment library. From there you can write tests that ensure moment was invoked appropriately. Source: almost 3 years ago
  • 16 Top NodeJS tools to make you a better developer
    SinonJS For testing JavaScript, you can use SinonJS, a stand-alone framework. Compatible with any testing framework, it's compatible with stubs, spies, and mocks. In addition, it's cross-browser compatible and runs on NodeJS on the server. ‍. - Source: dev.to / about 3 years ago
  • How to mock localStorage in JavaScript unit tests?
    I've been using Sinon.JS for most of my other javascript mocking and have found it is really great. Source: about 3 years ago
  • Wizard level tips for testing/QA JS browser code ? How do you ensure full coverage, generate test cases, etc ?
    My team uses Vue.js. We use Karma/Mocha/Chai and Sinon and Vue Test Utils to test our Vue components. For E2E testing we use Webdriver.io, but have in the past used Selenium written in Kotlin, and also Cypress. Source: about 3 years ago
  • Dependency Injection in JavaScript: Write Testable Code Easily
    Thanks to the magic of runtime reflection and the underlying dynamic nature of JavaScript, our testing framework will likely let us replace those components with hard-coded "mocks" on the fly. Jest, a popular JavaScript testing library, comes with this functionality baked in, and many other libraries provide it as well (such as SinonJS). - Source: dev.to / about 3 years ago
  • Creating a Chai like assertion library using proxies
    Assertions on mock functions (compatible with sinonjs and tinyspy). - Source: dev.to / over 3 years ago
  • Dealing With Test Doubles
    Fakes can be constructed without help from mocking frameworks such as Jest or Sinon. An example of a fake object in Typescript,. - Source: dev.to / over 3 years ago
  • Stubbing MQTT.js library in Ember.js tests with Sinon.JS
    After some experiments with the mock-socket library I realized that this tool was not anymore mantained and combining some searchs into the Sinon.JS documentation I found a way to stub the MQTT.js dependency faking the connect method. - Source: dev.to / over 3 years ago
  • Introduction to stubbing and test driven development
    During a previous software engineering internship, I was working on a NodeJS backend and had to write integration tests. We used mocha and chai as our Javascript test framework. However, there were times where we used external systems such as firebase or other external APIs in our backend logic. To mock that we used SinonJS and essentially verify whether specific functions are called, whether errors are thrown as... - Source: dev.to / over 3 years ago

Do you know an article comparing Sinon.JS to other products?
Suggest a link to a post with product alternatives.

Suggest an article

Sinon.JS discussion

Log in or Post with

Is Sinon.JS good? This is an informative page that will help you find out. Moreover, you can review and discuss Sinon.JS here. The primary details have not been verified within the last quarter, and they might be outdated. If you think we are missing something, please use the means on this page to comment or suggest changes. All reviews and comments are highly encouranged and appreciated as they help everyone in the community to make an informed choice. Please always be kind and objective when evaluating a product and sharing your opinion.