Ich habe eckig 2 Projekt mit eckigen-Cli erstellt. Ich habe ein separates AppRoutingModule erstellt, das RouterModule exportiert und zum Import-Array von AppModule hinzugefügt wird.Angular 2 - Testkomponente mit Router-Ausgang
Ich habe auch AppComponent von Angle-CLI erstellt.
app.component.html
<nav>
<a *ngFor="let view of views" routerLink="{{ view.address }}" routerLinkActive="active">{{ view.text }}</a>
</nav>
<router-outlet></router-outlet>
app.component.spec.ts
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('App: AquaparkFrontend',() => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
});
});
it('should create the app', async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have 3 views`,() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app.views.length).toEqual(3);
});
});
Wenn ich versuche, Tests mit ng Test auszuführen Ich habe Fehler:
Can't bind to 'routerLink' since it isn't a known property of 'a'. ("<nav>
<a *ngFor="let view of views" [ERROR ->]routerLink="{{ view.address }}" routerLinkActive="active">{{ view.text }}</a>
</nav>
<router-outlet><"
Vermisse ich etwas im Test zu importieren?