Javascript unit test with Jasmine, Angular, Chutzpah at Visual Studio

10/3/2015·1 min read

The following blog shows how to run the AngularJS unit test just like how you run C# unit test, so basically, you'll run your AngularJS at the visual studio test explorer window.

Install packages

You'll need to install the following two packages, AngularJS.Core and JasmineTest.

install-package AngularJS.Core
install-package JasmineTest

Create AngularJS app module

var app = angular.module('app', []);

Create AngularJS controller

Just create a simple controller with score.test is test.

app.controller('myController', function ($scope) {
    $scope.test = 'test';

Write Javascript Unittest

Following this, we'll create a Javascript unit test code by Jasmine.

/// <reference path="{{path to the javascript}}"/>
describe('testAngular ', function () {
    //initialize Angular
    var scope;
    beforeEach(inject(function ($controller, $rootScope) {
        scope = $rootScope.$new();
        var ctrl = $controller('myController', { $scope: scope });

    it('test scope is test', function () {

Get Chutzpah Test Adapter

Chutzpah Test Adapter for the Test Explorer

Once you install Chutzpah you can just run the unit tests like C# unit tests.