【发布时间】:2017-07-12 16:31:57
【问题描述】:
我有几个 .spec.ts 文件都需要以下 beforeEach:
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [FormsModule, HttpModule, CovalentHttpModule.forRoot({
interceptors: [{
interceptor: CustomInterceptorService, paths: ['**'],
}],
}),],
declarations: [LoginComponent],
providers: [AuthService, { provide: Router, useClass: class { navigate = jasmine.createSpy('navigate'); } }, LoggingService, CustomInterceptorService],
})
.compileComponents();
}));
有没有办法将此 TestBed 配置外包?现在我必须使用相同的导入和提供程序来调整每个新的测试文件。
我正在寻找类似基本单元测试的东西。茉莉花可以吗?
【问题讨论】:
-
by
base class你到底是什么意思
标签: javascript angular unit-testing typescript jasmine