'router-outlet' is not a known element

Probably I'm late here, but since I got the exaclty same issue and found an answer here.

Are you using angular-cli? https://github.com/angular/angular-cli/pull/3252/files#diff-badc0de0550cb14f40374a6074eb2a8b

In my case I just had to import my new router module in the app.component.spec.ts The js import and NgModule import.

Then restart the test server.


Like Erion said: In my case I did (added) two things in app.component.spec.ts:

import { RouterTestingModule } from '@angular/router/testing';
...
TestBed.configureTestingModule({ 
  imports: [ RouterTestingModule ],
  declarations: [
    AppComponent
  ],
}).compileComponents();