Take the 2-minute tour ×

I am looking for advice on TDD with JavaScript. I'm using VS 2010\2012 with Qunit and would like to know if it is best practice to:

  • use a mocking framework like Qmock or other?
  • use a code coverage tool like jsCoverage

I have seen articles like this but they tend to be older and I'm unsure if they are still relevant?

I understand that questions similar to this have been asked before such as Are there any good JavaScript code coverage tools? [closed] but again they are fairly old.

I'm just looking for a nudge in right the direction regarding current best practices on these two areas please?



share|improve this question

1 Answer 1

up vote 0 down vote accepted

If you are truly practicing TDD, then code coverage should be a non-issue. Don't worry about it. In general I believe that code coverage numbers cause more harm than good. The focus tends to be on the number. For example, if I have code that's been in production for 5 years, works, and never gets changed does it need to have tests? Not necessarily. In fact, adding tests risks breaking something that previously worked fine without them.

For mocking, it really depends on your needs. I've not used a mocking framework with JavaScript, I've just hand rolled any mocks I need, and I am happy with that solution.

Hope that helps!


share|improve this answer

Your Answer


