Pages

Monday, January 28, 2013

JavaScript Unit Testing in Visual Studio Part I

JavaScript is all around


caricature
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?

3 comments:

  1. Hadoop training institutes in hyderabad .All the basic and get the full knowledge of

    hadoop.
    hadoop training institutes in

    hyderabad

    ReplyDelete
  2. Big data and data warehousing related information is always updated to me at hadoop online training in hyderabad. Nice insight on the topic refer the details at
    hadoop online training

    ReplyDelete