【发布时间】:2016-12-03 05:08:53
【问题描述】:
我目前正在 Jasmine 中编写一个测试,使用 Karma 作为 JS 运行器。 “描述”中是否可以有多个“它”,如下所示:
describe('PhoneCat controllers', function() {
describe('PhoneListCtrl', function(){
it('should create "phones" model with 3 phones', function() {
var scope = {},
ctrl = new PhoneListCtrl(scope);
expect(scope.phones.length).toBe(2);
it('should create "greetings" models with 3 greeting', funciton(){
var scope = {},
ctrl = new PhoneListCtrl(scope);
expect(scope.greetings.length).toBe(3);
});
});
});
});
它目前失败了,但是你如何编写一个没有冗余的测试(在这种情况下,必须描述同一个控制器,两次)?
【问题讨论】:
标签: angularjs jasmine karma-runner