Software Alternatives & Reviews
Table of contents
  1. Videos
  2. Social Mentions
  3. Comments

Sinon.JS

Standalone test spies, stubs and mocks for JavaScript.

Sinon.JS Reviews and details

Screenshots and images

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

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.
  • 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 / 2 months 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 1 year 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 / about 1 year 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: about 1 year 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 / about 1 year 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 1 year 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 1 year 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 1 year 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: over 1 year 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 / almost 2 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 2 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 2 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 2 years ago
  • Creating a Chai like assertion library using proxies
    Assertions on mock functions (compatible with sinonjs and tinyspy). - Source: dev.to / about 2 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 2 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 2 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 2 years ago
  • Using Sinon, how can I stub the same dependency twice, so it returns a different value based on different input parameters?
    Hi all. I'm writing a unit test, and trying to use the Sinon package to ensure a particular dependency returns a different value, based on different parameters it is passed. I'm trying to use the withArgsmethod (see here). But when I do so, I encounter a console error:. Source: almost 3 years ago
  • [unit test] How to properly mock element.appendChild in my unit test?
    Hi all. I have a method which creates an HTML element and calls the appendChild method. I've now written a unit test for this method, and want to use the Sinon package to mock the call to appendChlid and count how many times it was called. But when I do that, Sinon reports it was called zero times, instead of one. How do I use Sinon to properly mock (spy) appendChild in this case? My code is below. Source: almost 3 years ago
  • Custom Arguments with Jest
    Jest is a powerful test runner, assertion library, and simple to use. Personally, It has replaced other configurations I've used like Mocha, Chai, Sinon for my Javascript testing. But one thing I really wished for, in Jest, is the ability to enable custom command line arguments. With custom arguments, I'm able to isolate testing configurations between npm scripts. Let's dive into what they are. - Source: dev.to / about 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

This is an informative page about Sinon.JS. You can review and discuss the product 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.