Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 874
jpgrace Avatar asked Aug 31 '12 13:08

jpgrace


1 Answers

* 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!

like image 80
Karthik Avatar answered Sep 23 '22 19:09

Karthik