[英]AngularJS Karma-jasmine and visual studio 2015
我有一個angularJS應用程序,現在我想開始對其進行測試。 因此,我看了一些教程,但沒有一個教程向您展示如何使用Visual Studio 2015進行測試。是否有人知道有用的閱讀資源或可以幫助我進行設置。
我的問題是:
提供的任何幫助都將非常棒。
我建議您嘗試Chutzpah(可以插入VS2015),它與Jasmine一起使用,您可以在VS輸出控制台和瀏覽器中查看測試結果。
我與Chutzpah在VS2015上的Helloworld示例:
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');
});
});
如果您使用的是karma茉莉花測試運行程序,則無需在vs15中進行任何設置,因此karma在其自己的虛擬服務器中運行測試,您可以在控制台本身中查看結果。 如果要調試測試以及文件,則在chrome瀏覽器中,您將看到調試按鈕,然后在下一個窗口中按f12鍵以在chrome中打開開發人員窗口。 Chutzpah也很好,但因果茉莉最適合Angular JS測試。 業力也很容易設置和使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.