Stephen Walther on Integrating JavaScript Unit Tests

| by Jonathan Allen Follow 499 Followers on Jan 19, 2011. Estimated reading time: 1 minute |

A note to our readers: You asked so we have developed a set of features that allow you to reduce the noise: you can get email and web notifications for topics you are interested in. Learn more about our new features.

In order to be considered suitable for automated testing, a unit testing framework needs to meet two important criteria. The first is of course the quality of the libraries with which you will build the tests themselves. The second criterion is that it integrates with your tool chain. For .NET developers, that means being able to run JavaScript tests inside your IDE and via your builds scripts. While most frameworks have focused exclusively on the former, Stephen Walther has been working on a solution to the second.

Stephen Walther’s full design can be seen in his post titled Integrating JavaScript Unit Tests with Visual Studio, so we are just going to hit the highlights.

The most important thing is that there is no browser component in his design. This has some interesting ramifications.

  • Since you don’t have to spin up browsers, the tests runs are naturally fast.
  • Likewise the environment is pure. Only the code you explicitly import into the test engine is in scope, nothing from the browser can leak in.
  • Since it is a clean, browserless environment you don’t have access to the DOM or other web-specific objects.
  • While perfect for pure JavaScript libraries, this is completely inappropriate for UI testing. (This could change with a heavy investment in mocking the web-specific objects.)

While any independent JavaScript engine would work for his purposes, Stephen has chosen the JScript engine shared by IE, Windows Script Host, and classic ASP. This has the advantage of being exposed to .NET both via the Windows Script Interfaces and the Microsoft Script Control.

From there he built a very primitive JavaScript testing library that bridges the gap between the JScript engine and the MSTest framework. Considering the simplicity of his design, this technique can be used to marry practically any combination of JavaScript testing library, JavaScript engines, and automated testing frameworks.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread


Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you