Jeanluca Scaljeri
Jeanluca Scaljeri

Reputation: 29169

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 ?

Cheers

Upvotes: 23

Views: 8835

Answers (3)

Benny Code
Benny Code

Reputation: 54925

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.

Upvotes: 7

Chris Clark
Chris Clark

Reputation: 4814

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.

Upvotes: 11

Andreas Köberle
Andreas Köberle

Reputation: 111042

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.

Upvotes: 16

Related Questions