Karma unit testing error: Unexpected value imported by the module. Please add a @NgModule annotation

You are injecting MatDialogRef in component: constructor(private dialogRef: MatDialogRef<Mytest1Component>) { } So the testBed expects the same to be injected as provider to the TestBed. Or you can also provide a MockDialogueService to it. beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ Mytest1Component ], providers: [ MatDialogRef ], }) .compileComponents(); }));

tech