Failed: Template parse errors:
Can't bind to 'routerLink' since it isn't a known property of 'a'. ("nd">
<img width="25" src="../assets/images/app_logo.jpg">
<a class="navbar-brand" [ERROR ->][routerLink]="['/avior/dashboard']"> === Application ===</a>
</a>
"): ng:///DynamicTestModule/AppComponent.html@7:27
...
NullInjectorError: StaticInjectorError[AviorBackendService]:
NullInjectorError: No provider for AviorBackendService!
...
Failed: Unexpected pipe 'SearchPipe' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation.
...
Expected undefined to be truthy.
Та же ошибка повторяется снова и снова для каждого якоря с [routerLink] внутри него ...
Я попытался импортировать RouterModule в app.component.ts И app.module.ts , но это, похоже, не помогает. Я также импортировал его в каждый файл .ts, где используется routerLink, но это тоже не помогло.
Я попытался импортировать import { RouterTestingModule } from '@angular/router/testing';
в spe c .ts, но это тоже не помогло, но я думаю, что это где-то в правильном направлении.
PS Я не изменил .spe c .ts файлы с одним исключением.
ОБНОВЛЕНИЕ
Мой компонент панели мониторинга spe c .ts:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { DashboardComponent } from './dashboard.component';
describe('DashboardComponent', () => {
let component: DashboardComponent;
let fixture: ComponentFixture<DashboardComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DashboardComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(DashboardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Мой компонент входа spe c .ts:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LoginComponent } from './login.component';
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ LoginComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoginComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Как вы можете видеть, они являются тестами по умолчанию.
В AppComponent. html@7: 27 проблема действительно была вложенной в якоря:
<a class="navbar-brand">
<img width="25" src="../assets/images/app_logo.jpg">
<a class="navbar-brand" [routerLink]="['/avior/dashboard']"> === Application ===</a>
</a>
Я изменил внешний якорь на div, но другие ошибки все еще сохраняются.