0
I am doing unit testing in an application of mine. I am beginner regarding testing, so I need your help.
In my application I do a service using Matdialog ( Kdsdialogservice).
I have tried putting many import alternatives, my service or matdialog as providers I have no more idea what to do
export declare class KDSDialogService {
dialog: MatDialog;
private dialogRef;
constructor(dialog: MatDialog);
open(componentOrTemplateRef: ComponentType<any> | TemplateRef<any>, title?: string, data?: any, size?: DialogSize, showClose?: boolean): MatDialogRef<any, any>;
static ɵfac: ɵngcc0.ɵɵFactoryDef<KDSDialogService, never>;
}
And on my home.component.spec I import and make the statements here, but still I get this error. Again, I’ve tried putting as Provider the service but I haven’t managed yet, here are alternatives of my despair
describe('HomeComponent', () => {
let component: HomeComponent;
let fixture: ComponentFixture<HomeComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [HomeComponent ],
imports:[KDSDialogService, MatDialogModule],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent);
component = fixture.componentInstance;
});
it('should create', () => {
fixture.detectChanges();
expect(component).toBeTruthy();
});
});
You can try mock your service.
– Bruno Cunha