我正在尝试对使用 angular-material2 的组件编写测试,但是当我将其添加到我的 testModule 声明中时,我得到:
Error: Template parse errors:
'md-card-title' is not a known element:
1. If 'md-card-title' is an Angular component, then verify that it is part of this module.
2. If 'md-card-title' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message.
将 MaterialModule 添加到声明中会引发“错误:模块声明的意外模块“MaterialModule”
config/spec-bundle.js 中的 DynamicTestModule'(第 24994 行)
这是我的规范文件的样子:
beforeEach(() => TestBed.configureTestingModule({
declarations: [],
providers: [
{ provide: DataService, useValue: mockDataService },
{ provide: ActivatedRoute, useClass: MockActivatedRoute },
{ provide: Router, useValue: mockRouter },
CellViewComponent
]
}));
添加CellViewComponent
到声明数组会导致错误抛出。