Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS testing using Jasmine + Karma in Visual Studio 2013

I am new to Angularjs framework and also testing it using Jasmine framework and Karma. I have a ASP.NET MVC app built with Visual Studio 2013 and I would like to include Jasmine package and Karma in order to test js.

Maybe this issue is already discussed here, but could you please show a tutorial or a demo of how to include a Jasmine file, and test it and show the results? For testing spa app is Jasmine and Karma the best choice?

Could you please show me some steps of where to include Jasmine in project and how to bind it with my .js in order to test it?

like image 737
studentsss Avatar asked Mar 21 '14 15:03

studentsss


1 Answers

I ran into the same issue - all of the tutorials seem to be based on Node.js. However, I found some excellent resources to get started with from the Chutzpah Javascript Test Runner project. Chutzpah appears to support QUnit, Jasmine, and Mocha testing frameworks. Essentially, install the packages/extensions listed below, follow the Jasmine tutorials for building out unit tests on the Pivotal Gist (or the Angular demo), and you'll be able to right-click (to pull up the context menu) on a Javascript test and run it (selecting the option "Run JS Tests"). Hope these resources help!

Visual Studio Extensions:

  • Chutzpah Test Adapter for Test Explorer (VS2012/2013 support)
  • Chutzpah Context Menu Extension (VS2012/2013 support)
  • Jasmine NuGet Package

Tutorials

  • Yuriy Tyukhnin's tutorial
  • Rosher Consulting's tutorial

Edit: Because it has been linked here, I also threw a blog post together about this - http://codeforcoffee.org/Setting-Up-Angular-JS-Jasmine-and-Karma-in-Visual-Studio

like image 185
code4coffee Avatar answered Oct 20 '22 12:10

code4coffee