gpt4 book ai didi

angular6 - 非法状态 : Could not load the summary for directive AppComponent

转载 作者:行者123 更新时间:2023-12-04 01:52:11 26 4
gpt4 key购买 nike

我正在以 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 中使用的所有组件在 declarationconfigureTestingModule

关于angular6 - 非法状态 : Could not load the summary for directive AppComponent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52495262/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com