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

Angular 2 - Karma coverage reporter misses statements inside fakeAsync() calls

如果在测试期间将它们放入 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);
      });
  });
});

会造成业力上报

statement not covered and lower coverage percentage.

我该如何解决这个问题?

你好像打错了。正确的语法应该是:

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