我正在以 angular 编写 spec.ts 文件并收到以下错误:
Failed: Illegal state: Could not load the summary for directive AppComponent.
下面是我试过的代码
import { TestBed, async } from "@angular/core/testing";
import { AppComponent } from "./app.component";
describe('AppComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
});
});
});
it('should create the app', async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));``
最佳答案
您似乎正在使用一个包含其他组件的组件。您必须添加您在 AppComponent
中使用的所有组件在 declaration
的 configureTestingModule
关于angular6 - 非法状态 : Could not load the summary for directive AppComponent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52495262/