setup Chutzpah for running unit test


Chutzpah is a open source javascript test runner that allows you to run unit test using qunit, jasmine, mocha, coffeescript and most importantly typescript.

What in the world are you using Chutzpah for unit testing? Well, many teams started to writing their
angularjs code in typescript.

In this post, we're going to run our typescript unit test. First we need to setup our tool.

1. install Chutzpah test runner context menu extension - this allows you to right click on a file and runs a test. Life is easy.

Restart  your visual studio and you're good to go.

2. You probably need to setup jasmine as your unit testing framework. For more information, please  following instruction here.

Lets start with configuring our test runner and we're going to go with jasmine. Let's create new file called chutzpah.json and it should have the following contents :-



Lets create a simple typescript test and you can right click on it to run a unit test.

Debugging jasmine unit test

To debug unit test in jasmine using Chutzpah, you need to right click on the typescript test and then choose "open in browser". Go to chrome developer tool mode, proceed to  'Sources' and then you look for "yourUnitTest.test.js" file as shown below :-




Place a breakpoint and then hit refresh. You are now in debug mode - easy! :)

References 

Jasmine testing with typescript 101

https://angular.io/docs/ts/latest/testing/jasmine-testing-101.html

Jasmine unit test result matcher

http://jasmine.github.io/2.0/introduction.html

Comments

Popular posts from this blog

ionic2 cordova build android - Unable resolve gradle 2.2.3

OpenCover code coverage for .Net Core

Using Custom DLL with IronPython / Scripts