Angular 9 "Error: This constructor was not compatible with Dependency Injection."

You set a Router as provider in your test. That's not the way to do that.

You should import the RouterTestingModule in your test to be able to access it.

beforeEach(async(() => {
  TestBed.configureTestingModule({
    imports: [RouterTestingModule],
    declarations: [AppComponent],
    providers: [AuthService],
  }).compileComponents();
}));
I guess with ivy and/or angular 9, they declared the `providedIn` from the router service in such a way that you cannot provide it in another module anymore (which you should never do anyways :))

Background info:

Looking at the source code, you can see they inject the router in a special way using a factory. The router class itself is just a normal class with no @Injectable() decorator.


Another source of this error (not related to the OP's question) can be when you have a constructor param with a default arg such as:

constructor(someProp: string = 'propVal') {
    this.someProp = someProp;
}

You can resolve it by doing this instead:
constructor(@Inject('propVal') @Optional() someProp: string) {
    this.someProp = someProp;
}