Angular Material and Jasmine : “ No provider for InjectionToken MdDialogData! ”

前端 未结 6 2099
醉梦人生
醉梦人生 2021-02-01 12:12

I have a component which is meant to be used in an Angular Material MdDialog :

@Component({
  ...
})
export class MyComponent {

  constructor(@Inject(MD_DIALOG_         


        
6条回答
  •  执念已碎
    2021-02-01 12:52

    try this

    beforeEach(async(() => {
     TestBed.configureTestingModule({
       imports: [
         SharedTestingModule,
       ],
       declarations: [
         MyComponent,
       ],
       providers: [ <-- here
        {
         provide: MdDialogData,
         useValue: {},
        }
       ] <-- to here 
     })
     .compileComponents();
    }));
    

    let me know how it goes

提交回复
热议问题