伊斯坦布尔

时间:2016-04-10 21:30:03

标签: javascript unit-testing jasmine istanbul

我已经配置了工具karma-coverage来衡量我的代码覆盖率。 Hovewer我注意到在某些情况下它无法识别我的代码是否在测试期间被调用。这是我在测试中使用的样本:

伊斯坦布尔未正确检测到此测试:

it('should throw an error if credentials.username is not defined', function() {
   expect(function(){
       currentAuthProvider.authenticate({
           password: '123456'
       }).toThrowError('Parameter credentials.username should be defined.')
   });
});

我已将测试更改为此表单,该表单已正确捕获:

it('should throw an error if credentials.username is not defined', function() {
   try{
      currentAuthProvider.authenticate({
         password: '123456'
      })
   } catch(e){
         expect(e.message).toEqual('Parameter credentials.username should be defined.');
   }
});

我想在第一次测试时以形式编写我的测试。在第一种情况下,代码覆盖率显示currentAuhProvider.authenticate函数未被单元测试覆盖,但在第二种情况下,正确的结果显示在代码覆盖率结果中。有没有其他方法可以影响伊斯坦布尔检测第一个测试并将其计算到代码覆盖范围内?

0 个答案:

没有答案