I had the same error when I updated Angular to version >= 9 (Token InjectionToken XxXxXxXx is missing a ɵprov definition), especifically when I ran tests and these tests had providers as MatDialogRef and MAT_DIALOG_DATA from Angular Material.
My solution was replace the providers config in the beforeEach() section. look at:
Before:
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
beforeEach(async(() => {
TestBed.configureTestingModule({
imports : [
...
],
declarations: [
...
],
providers: [
{ provide: MatDialogRef },
{ provide: MAT_DIALOG_DATA }
]
}).compileComponents();
}));
After:
import { MAT_DIALOG_DEFAULT_OPTIONS } from '@angular/material/dialog';
beforeEach(async(() => {
TestBed.configureTestingModule({
imports : [
...
],
declarations: [
...
],
providers: [{
provide: MAT_DIALOG_DEFAULT_OPTIONS, useValue: {hasBackdrop: false}
}]
}).compileComponents();