← back to the blog

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

Posted in Jasmine, Angular.js, Visual Studio, JavaScript by dake

Do you want to test javascript at visual studio Test Explorer windows?

Let's assume you want to test angular.

I'll explain that at this blog.

1. First you need to install Angular if you don't have it.

install-package AngularJS.Core

2. Than you need to install Jasmine

install-package JasmineTest

3. start create angular app.js

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

4. start create angular controller

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

5. write test using jamine

/// <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 () {

6. Get Chutzpah Test Adapter

Chutzpah Test Adapter for the Test Explorer


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