テストフィクスチャに次の構成を使用すると、タグが見つからないという苦情があります。 AppModule
に直接MockSelectionToolComponent
を代入するので、実際には、我々はテストモジュールの宣言に、しかし、元のモジュールに追加していない正常に動作しますので、何か他のものでなければならない...angularテストベッドオーバーライドモジュールが動作しない
// Add the imported module to the imports array in beforeEach
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [MockSelectionToolComponent],
imports: [
AppModule
]
}).overrideModule(AppModule, {
remove: {
declarations: [SelectionToolComponent]
}
}).compileComponents();
fixture = TestBed.createComponent(MappingComponent);
component = fixture.componentInstance;
fixture.detectChanges();
component.initialiseMap();
});
Error: Template parse errors: 'app-selection-tool' is not a known element: