AngularJS Karma-jasmine和视觉工作室2015

r3p*_*ica 6 testing angularjs karma-jasmine visual-studio-2015

我有一个angularJS应用程序,现在我想开始测试它.所以我看了几个教程,但没有一个教你如何使用visual studio 2015设置测试.有没有人知道一个好的资源阅读或可以帮助我设置它.

我的问题是:

  1. 我是否需要为每个测试设置单独的视图?
  2. 除了安装karma-jasmine和karma-chrome-launcher之外我还需要安装其他东西吗?
  3. 如何在浏览器中查看我的测试?

任何帮助都会很棒.

Cey*_*baş 3

我会推荐你​​尝试Chutzpah(可以插入VS2015),它与Jasmine配合使用,你可以在VS输出控制台和浏览器中看到测试结果。

Github 上的厚颜无耻

VS 的 Chutzpah 扩展

我在 VS2015 上使用 Chutzpah 的 Helloworld 示例:

你好世界.js:

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

你好世界规范.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');
    });
});
Run Code Online (Sandbox Code Playgroud)