Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal state: Could not load the summary for directive AppComponent

Tags:

angular6

I am writing a spec.ts file in angular and getting the following error:

Failed: Illegal state: Could not load the summary for directive AppComponent.

Below is the code I tried

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();
    }));``
like image 700
Arpita Gupta Avatar asked Dec 21 '25 03:12

Arpita Gupta


1 Answers

It seems that you're using a component which includes another components inside. You have to add all the components that you used in AppComponent in declaration of configureTestingModule

like image 149
Nima Boobard Avatar answered Dec 24 '25 11:12

Nima Boobard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!