How to mock NSURLConnection.sendAsynchronousRequest in unit testing?

What is a good unit testing framework for a JavaScript project using Backbone.js, grunt, and phantom.js?

  • Hey all, I am working on a large enterprise JavaScript project and have to chose a unit testing framework before we go ahead. The unit testing will mostly test backbone.js scripts. I am currently trying to decide between Jasmine/ http://Intern.io/ quint. I wanted quoras input on the subject. Can anyone speak to the pros and cons of each, other suggestions welcome. We are using grunt and phantom.js. Thanks quora!

  • Answer:

    For unit testing, the choice for me is usually between Jasmine and Mocha+Chai+Sinon. Most new projects in JS I see going on usually have their unit tests in one of those frameworks. Mocha's selling point is its flexibility (which means you have to pair it with Chai for assertions and Sinon for stubs/mocks). However, Jasmine and Mocha+Chai+Sinon are both really really similar, so it depends on whether you want the pick-and-choose approach or the batteries-mostly-included approach (Jasmine). One thing to note is that with Jasmine, you will want to pair it with jasmine.async because Jasmine's builtin async testing sucks. I've never used http://theintern.io, but it seems really interesting. I'll have to look into it. I've never used QUnit so I can't comment on that.

Brian Chu at Quora Visit the source

Was this solution helpful to you?

Other answers

Vows is another popular choice - http://vowsjs.org/ though I use Jasmine myself...

Brian Takita

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.