首页 > 解决方案 > 如何在角度 4 中运行单元测试特定组件

问题描述

有没有办法只为 angular 4 项目中的特定组件运行单元测试?

标签: angularunit-testing

解决方案


将 f 添加到describe关键字以使其集中。使用fdescribe. 这将只运行焦点组件。

fdescribe('MyComponent', () => {
  let component: MyComponent;
  let fixture: ComponentFixture<MyComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ MyComponent ]
    })
    .compileComponents();
  }));


  it('should be created', () => {
    expect(component).toBeTruthy();
  });
});

推荐阅读