在Angular的Jasmine测试用例中配置TestBed的推荐方法是什么?

问题描述

我已经开始为Angular编写测试用例,并且在阅读来自互联网的文章时,我发现我们可以使用不同的方法来配置TestBed。以下是一些示例:

示例1:

beforeEach(async(() => {
  TestBed.configureTestingModule({
   ...
  }).compileComponents()
    .then(() => {
      fixture = TestBed.createComponent(Component);
      component = fixture.componentInstance;
      fixture.detectChanges();
    });
}));

示例2:

beforeEach(async(() => {
  TestBed.configureTestingModule({
   ...
  }).compileComponents();
}));
beforeEach(() => {
  fixture = TestBed.createComponent(Component);
  component = fixture.componentInstance;
  fixture.detectChanges();
});

示例3:

beforeEach(async(() => {
  TestBed.configureTestingModule({
   ...
  }).compileComponents();
  fixture = TestBed.createComponent(Component);
  component = fixture.componentInstance;
  fixture.detectChanges();
}));

示例4:

beforeEach(async() => {
  TestBed.configureTestingModule({
   ...
  });
  await TestBed.compileComponents();
  fixture = TestBed.createComponent(Component);
  component = fixture.componentInstance;
  fixture.detectChanges();
});

我需要帮助以了解建议采用哪种方法?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)