jpgrace
jpgrace

Reputation: 401

What's the advantage of using Sinon.js over Jasmine's built in Spys?

I'm piecing together a jsTestDriver/Jasmine environment for testing our front end code and I'm seeing a lot of references to Sinon.js for stand-alone (or drop in) spies. Could someone describe what Sinon.js brings to the table that Jasmine doesn't for testing the UI?

Upvotes: 20

Views: 3634

Answers (1)

Karthik
Karthik

Reputation: 1006

* Posting it as an answer, since this didn't fit in the Comments section! *

FWIW, We used SinonJS to create a FakeHTTP(LinearEPG)server component for implementing the REST-APIs of the real-server that hosts the EPG(Linear TV Program Schedule) info.

Then, we used this FakeHTTP-LinearEPG server in two modalities:

  1. Used with the Web-App displaying EPG for testing the navigation etc.
  2. Test the Javascript-code that fetches the EPG along with Jasmine UT Specs.

Granted, we could have implemented the FakeServer functionality using Jasmine-Spies, but it seemed to be bit convoluted. On the other hand, the FakeServer provided an elegant and quick way to emulate the Server providing the REST-interfaces.

SinonJS-based FakeServer proved to be quite useful when the server itself was still under development at that time!

Upvotes: 5

Related Questions