Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS Karma-jasmine and visual studio 2015

I have an angularJS application and now I would like to start testing it. So I have watched a few tutorials, but none of them show you how to set up testing with visual studio 2015. Does anyone know about a good resource to read or can help me set it up.

The questions I have are:

  1. Do I need to set up separate views for each test?
  2. Apart from installing karma-jasmine and karma-chrome-launcher do I need to install anything else?
  3. How can I view my tests in a browser?

Any help given will be awesome.

like image 762
r3plica Avatar asked Apr 29 '16 13:04

r3plica


1 Answers

I will recommend you to try Chutzpah (can be plugged in VS2015), it works with Jasmine, you can see test results in the VS output console and also in browser.

Chutzpah on Github

Chutzpah extensions for VS

My Helloworld examples on VS2015 with Chutzpah:

helloworld.js :

function helloWorld(){
    return "Hello world!";
}
function examples() {
    return package = {
        first: 13,
        second: 13,
        third: "gone"
    }
}

helloworldspec.js :

/// <reference path="helloworld.js" />

describe("Hello world", function () {
    it("says hello", function() {
        expect(helloWorld()).toContain("Hello");
    });
});
describe("Examples", function () {
    it("examples", function () {
        expect(examples().first).toBe(13);
        expect(examples().third).not.toBe(13);
        expect(examples().third).not.toMatch(/gz/);
        expect(examples().third).toMatch('go');
    });
});
like image 121
Ceylan Mumun Kocabaş Avatar answered Oct 04 '22 20:10

Ceylan Mumun Kocabaş