Angular 2 - Karma报道记者错过了fakeAsync()调用中的语句

时间:2017-09-25 19:12:29

标签: angular karma-runner

我的报道记者未能检测到在测试期间将其放入fakeAsync()中时使用的语句:

describe('countWords', () => {
  it('should total number of words in string; should be 2 for "butt heaven" ', () => {
    expect(comp.countWords('butt heaven')).toBe(2);
  });
});

检测不到但......

describe('countWords', () => {
  it('should total number of words in string; should be 2 for "butt heaven" ', () => {
      fakeAsync( () => {
        expect(comp.countWords('butt heaven')).toBe(2);
      });
  });
});

会导致业力报告

  

声明未涵盖且覆盖率较低。

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

看起来你输错了。正确的语法应该是:

it('Some description', fakeAsync(() => {
   expect(comp.countWords('butt heaven')).toBe(2);
}));