Does jasmine need sinon.js?

I’ve seen examples on the web in which people use jasmine together with sinon. However, jasmine has support for spies (which as I understand is what Sinon does). So, the question is, is Sinon still useful when using Jasmine ? If Sinon is useful what exactly makes it a good addition to jasmine ?


No you dont need Sinon to work with Jasmine. But Sinon spy/mock/stubs are more convenient in some cases. There is also a minor bug in mocking setTimeout in Jasmine, which work as expected with sinon.

I use Sinon with Jasmine for it’s fakeServer capabilities. Sinon allows me to easily mock AJAX HTTP requests without relying on the state of my server. Sinon also provides lower-level http mocking functionality for when you really need to fine-tune your mocked services.

You can use SinonJS as an extension to Jasmine. Sinon has a very nice API for a mock server which is quite handy if you want to test REST calls without having a real backend. There is also a nice documentation which shows the combination of SinonJS with Jasmine.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .
Read More:   jQuery DIV click, with anchors

Similar Posts