我想在我的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执行测试后运行代码的测试块。不知道为什么...... –