r3plica
r3plica

Reputation: 13397

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.

Upvotes: 6

Views: 1640

Answers (2)

Debasis Mondal
Debasis Mondal

Reputation: 65

If you are using karma jasmine test runner then you don't have to setup anything in vs15, karma runs the test in it's own virtual server and you can see the result in the console it self. And if you want debug your test as well as your file then in the chrome browser you'll see the debug button press that and in the next window press f12 key to get the developer window in chrome. Also Chutzpah is good but karma jasmine is best for Angular JS testing. Also karma is very easy to setup and use.

Upvotes: -1

Ceylan Mumun Kocabaş
Ceylan Mumun Kocabaş

Reputation: 527

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');
    });
});

Upvotes: 3

Related Questions