Created
July 18, 2018 12:17
-
-
Save KarolinaCzo/d9e3a1d491bae065df94a6271ebe777b to your computer and use it in GitHub Desktop.
Resolving 'AppComponent › should create the app'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// After runing tests this error occur: | |
// Template parse errors: | |
// 'app-main-page' is not a known element: | |
// 1. If 'app-main-page' is an Angular component, then verify that it is part of this module. | |
// 2. If 'app-main-page' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ( | |
// Solution below | |
// Code from: 'app.component.spec.ts' | |
import { TestBed, async } from '@angular/core/testing'; | |
import { AppComponent } from './app.component'; | |
import { MainPageComponent } from './main-page/main-page.component'; | |
describe('AppComponent', () => { | |
beforeEach(async(() => { | |
TestBed.configureTestingModule({ | |
// The code failed at this point because there should been | |
// 'MainPageComponent' added to 'declarations' | |
declarations: [AppComponent, MainPageComponent] | |
}).compileComponents(); | |
})); | |
it('should create the app', async(() => { | |
const fixture = TestBed.createComponent(AppComponent); | |
const app = fixture.debugElement.componentInstance; | |
expect(app).toBeTruthy(); | |
})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment