我想在我的Angular應用程序上設置Jasmine測試來測試控制器。茉莉花測試不運行
控制器:
var navigation = angular.module("navigation", []);
navigation.controller("NavigationController", ['$scope', function ($scope) {
$scope.myObject = [];
$scope.tabs = [
{ title: "Surcharge Index", content: "SurchargeIndex" },
{ title: "Scheduling and Adjustments", content: "Scheduling" },
{ title: "Auto Update Settings", content: "Automation" },
{ title: "Processing Rules", content: "FuelProcessing" },
{ title: "Data Update ", content: "DataUpdate" },
];
}]);
測試:
describe("NavigationController", function() {
var scope;
var controller;
//beforeEach(module('app'));
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
controller = $controller('NavigationController', { '$scope': scope });
}));
it("scope is defined", function() {
expect(scope).toBeDefined();
//expect(scope.tags[0].title).toBe('Doe Index');
});
it("should contain a list of tabs", function() {
//expect(scope).toBeDefined();
expect(scope.tags).toContain({ title: 'Doe Index' });
});
});
無論茉莉花測試有史以來運行。
測試頁:
Jasmine2.0.0finished in 0.001s
raise exceptions
Ran 0 of 2 specs - run all
0 specs, 0 failures
NavigationController
scope is defined
should contain a list of tabs
這是茉莉花返回。出於某種原因,沒有任何測試正在運行。
有什麼建議嗎?
看起來好像是在jasmine執行測試後運行代碼的測試塊。不知道爲什麼...... –