【发布时间】:2016-10-06 06:10:19
【问题描述】:
我是 Angular 2 的 Jasmine 新手,在编写测试用例时我经常使用 TestBed 对象并收到错误:Please call "TestBed.compileComponents" before your test.
我该如何解决这个错误?
@Component({
moduleId:module.id,
selector: 'my-app',
templateUrl: 'app-component.html',
})
【问题讨论】:
-
你试过打电话给
TestBed.compileComponents()吗?TestBed是一个模拟环境,可以在没有浏览器的情况下运行 Angular2 组件测试。 -
是的,但现在显示错误:无法创建组件 AppComponent 因为它没有导入到测试模块中!
标签: angular jasmine karma-jasmine angular2-testing