TDD / Unit Testing JavaScript in Visual Studio using Jasmine and Chutzpah


In this post we will see how to unit test JavaScript in Visual Studio using Jasmine and Chutzpah. We will use Visual Studio’s built-in Test Explorer window for displaying the results. Jasmine is a an open source unit testing / behavior-driven framework. It lets us write test cases. Chutzpah is an open source test runner. It runs jasmine tests, pulls in the results and displays them in Visual Studio’s Test Explorer window. It utilizes phantomjs framework, under the hood, for pulling in the results.

Let’s do some homework and create a bunch of JavaScript functions that we will unit test.


var SimpleCalculator = function () {
    this.square = function (num1) {
        return num1 + num1;

    this.sum = function (num1, num2) {
        return num1 * num2;

Notice, we have added logical errors to the code so that tests can fail.

Next, we will add some extensions / NuGet packages to perform unit testing. 

Adding Jasmine framework

1. Right click the project and click Manage NuGet Packages

2. Search for Jasmine and install it


3. Notice Jasime has added a bunch of files.


Installing Chutzpah extension

1. In Tools menu, click Extensions and Updates

2. Search for Chutzpah and install Chutzpah Test Adapter for the Test Explorer


3. After installing Chutzpah, restart Visual Studio

4. In Tests menu, click Windows > Test Explorer. This is where all tests will show up.

Create unit tests using Jasmine framework

1. Create another JavaScript file where we will organize tests for SimpleCalculator that we created previously. Let’s name the file SimpleCalculator_Tests.js. Here are the file contents:


/// <reference path="../jasmine/jasmine.js" />
/// <reference path="../SimpleMath.js" />
describe("SimpleMath_Test", function () {
 var sc = new SimpleCalculator();

    it("sum_test", function () {
 var num1 = 5;
 var num2 = 6;
 var expected = 11;
 var actual = sc.sum(num1, num2);

    it("square_test", function () {
 var num1 = 5;
 var expected = 25;
 var actual = sc.square(num1);


As soon as we write a test, it appears in the Test Explorer win

dow. This is happening due to the Chutzpah plugin.


Running tests

In the Text Explorer, click Run All. Notice both tests have failed.


Go back to your original SimpleCalculator.js, fix the issues by changing operators used in sum and square functions and run the tests again. Notice, this time they have both passed.



Both Jasmine and Chutzpah are open source and make it very easy to unit test JavaScript code. It can be used with plain vanila JavaScript with libraries like JQuery and with frameworks like AngularJS etc.

Web Application Compatibility Lab Kit

Internet Explorer has seen several iterations over the past 20 years. IE 11 is the last version of Internet Explorer. Microsoft Edge is the future of web browser which got introduced in Windows 10. Internet Explorer, in the past, was a Software-as-a-Product. Where as Microsoft Edge is a Software-as-a-service and will be continuously updated. IE 11 is recommended for legacy websites that relies on legacy binary extensions, such as ActiveX controls, and legacy CSS concepts, such as CSS expressions. Microsoft Edge is meant for the modern web HTML5/CSS3 etc. Ideally, all websites should be upgraded to the modern web standards but it’s a fact it’s a very resource intensive process. So, while we are upgrading older web sites to support the modern standards, we still have to satisfy customers by letting them use older web sites in a newer version of web browser. That’s where we have to rely on various compatibility options provided by the browser, such as Enterprise Mode, Enterprise Site Discovery etc.

Web Application Compatibility Lab Kit is a primer for the features and techniques used to provide web application compatibility  during migration. Download link is available on this webpage:

What are “Server Roles” / MinRole in SharePoint 2016?

Installation of older versions of SharePoint is agnostic of role. It’s the services that farm admins provision that determines the server role. E.g. on a search server, farm admins provision Search Service and the related services. Similarly different set of services are provisioned on an application server and front-end server.


SharePoint 2016 introduces a concept called MinRole, aka. Server Roles, which is designed to transform guidance to code. This concept helps in implementing best practices for optimizing performance for the role type. MinRole/Server Role can be configured both by using powershell (PSConfig) and the gui (PSConfigUI)