This has been asked before and I did all the suggested comments but none seem to work. I am having a combo of an issue. Getting wallaby.js to work with my project and figure out the error when I run ng test
.
Can't bind to 'routerLink' since it isn't a known property of 'a'. ("<header id="header"> <h1 id="logo"> <a [ERROR ->][routerLink]="['/home']"></a>
</h1>
"): AppComponent@2:5
Can't bind to 'routerLink' since it isn't a known property of 'a'. ("
<div id="menu">
<a [ERROR ->][routerLink]="['/home']" class="btn">Home</a>
<a [routerLink]="['/about']" class="btn">About</a>
"): AppComponent@6:5
Can't bind to 'routerLink' since it isn't a known property of 'a'. ("
<div id="menu">
<a [routerLink]="['/home']" class="btn">Home</a>
<a [ERROR ->][routerLink]="['/about']" class="btn">About</a>
<a [routerLink]="['/experiments']" class="btn">Expe"): AppComponent@7:5
Can't bind to 'routerLink' since it isn't a known property of 'a'. ("terLink]="['/home']" class="btn">Home</a>
<a [routerLink]="['/about']" class="btn">About</a>
<a [ERROR ->][routerLink]="['/experiments']" class="btn">Experiments</a>
</div>
"): AppComponent@8:5
'router-outlet' is not a known element:
1. If 'router-outlet' is an Angular component, then verify that it is part of this module.
2. If 'router-outlet' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("
<div id="container">
[ERROR ->]<router-outlet></router-outlet>
</div>
"): AppComponent@18:1
My NgModule
import {BrowserModule} from "@angular/platform-browser";
import {NgModule,CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";
import {FormsModule} from "@angular/forms";
import {HttpModule} from "@angular/http";
import {RouterModule} from "@angular/router";
import {HomeComponent} from "./home/home.component";
import {ExperimentsComponent} from "./experiments/experiments.component";
import {AboutComponent} from "./about/about.component";
import {AppComponent} from "./app.component";
import {ExperimentsService} from "./common/experiments.service";
import {StateService} from "./common/state.service";
import {ExperimentDetailComponent} from "./experiments/experiment-details/experiment.detail.component";
@NgModule({
declarations: [
AppComponent,
AboutComponent,
HomeComponent,
ExperimentsComponent,
ExperimentDetailComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot([
{path: '', redirectTo: '/home', pathMatch: 'full'},
{path: 'home', component: HomeComponent},
{path: 'about', component: AboutComponent},
{path: 'experiments', component: ExperimentsComponent},
{path: '**', component: HomeComponent}
])
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
providers: [
ExperimentsService,
StateService
],
bootstrap: [AppComponent]
})
export class AppModule {
}
This is the only module. It is a simple application:
I have also posted the project on GitHub HERE
--------------------- Answer and the explanation is below------------
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import {RouterTestingModule} from "@angular/router/testing";
import {HomeComponent} from "./home/home.component";
import {AboutComponent} from "./about/about.component";
import {ExperimentsComponent} from "./experiments/experiments.component";
describe('AppComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule.withRoutes([
{path: '', redirectTo: '/home', pathMatch: 'full'},
{path: 'home', component: HomeComponent},
{path: 'about', component: AboutComponent},
{path: 'experiments', component: ExperimentsComponent},
{path: '**', component: HomeComponent}
])
],
declarations: [
AppComponent
],
});
TestBed.compileComponents();
});
it('should create the app', async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
});
However now I am getting Failed: Component HomeComponent is not part of any NgModule or the module has not been imported into your module.
Error: Component HomeComponent is not part of any NgModule or the module has not been imported into your module.
But HomeCompenent is clearly in my @NgModule