Monday, January 28, 2013

JavaScript Unit Testing in Visual Studio Part I

JavaScript is all around

If you're building complex SPAs (single page applications) with ASP.NET MVC, or native-like Apps for smartphones using frameworks like PhoneGap (yeah, yeah it's Cordova now, just that PhoneGap sounded much better) or alike, then JavaScript plays a big role in your day to day work. Not to mention Node.JS and Windows 8 Metro Style Applications...

The days where JavaScript has been used for small client-side manipulation, and jQuery alone was enough to overcome browser compatibility issues is long gone.

And with the boost of HTML5, and tremendous improvements in performance in modern web browsers, you can say what you want, but C# is not enough anymore.

That being said, how should we tackle complex projects where JavaScript lines of code are running high?

Unit Testing, in that sense, can help by keeping complex things more simple.

If you are an architect in a project, and you aim for quality, then you got to give your teams the right tools to come up with maintainable projects.

Picking The Tools

When you go out there and pick your JavaScript libraries for your next project, and I must admit it becomes a very nontrivial task those days with libraries like jQueryMobileBackbone.JS, KnockOut, AngularJS and many more..., then you should also take into account those libraries that will assist you and your team to write and run your unit tests in your development environment. 

As a .Net architect, my main development environment is Visual Studio, so my goal was to come up with a set of libraries that will allow me and teams I work with to do unit testing in Visual Studio, pretty much in same way we've been doing it with other .Net Unit Testing libraries.

Let's set the expectations

What do we want to accomplish?
  • Seamless integration with Visual Studio.
    So we can run tests without leaving the IDE.
    (In any case, this is the Post's title right?)
  • Headless testing.
    Against multiple browsers at the same time if possible.
    Later we will want to take it a step forward and automate it as part of CI (Continuous Integration), right?
  • Support for AMD (Asynchronous Module Definition) / Require.JS.
  • Support for Async Tests.
  • Documented libraries & Tools.
  • Free Tools are preferred.

Libraries & Tools

Eventually I came up with the combination of the tools listed below:

I can definitely say I'm quite happy with this combination. 

In following posts of this series I'm going to describe in details how to combine those tools to play together.

What tools/libraries do you use for Unit Testing Java Script in a Visual Studio/TFS development environment?


  1. Unbelievable. This post is written so well and contains each & every aspect that one must have. Project Viewer 365 Enterprise Crack Key is also in same format. Try this one too.

  2. Congratulations on your article, it was very helpful and successful. b9e5ed0164b3ad18998dbac7bfe1e062
    sms onay
    website kurma
    numara onay

  3. Thank you for your explanation, very good content. 2ff5a0154a09568839fe284c8702170c
    altın dedektörü