I don't get what I'm doing wrong, I didn't find any link of RouterLinkWithHref to any error in tests, furthermore I'm not using RouterLinkWithHref anywhere, as far as I know :/
Can anyone help me with this:
fdescribe('AddItemComponent: ', () => {
let cmp: AddItemComponent;
let fixture: ComponentFixture<AddItemComponent>;
let de: DebugElement;
let el: HTMLElement;
const mockRouter = {
navigate: jasmine.createSpy('navigate')
};
const mockCustomCardService = {
getItemDeliveryDate: () => Observable.empty(),
emitItemChanges: () => Observable.empty(),
};
const mockActivatedRoute = { snapshot: {} };
const mockPageDataService = {};
const mockUserService = {};
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AddItemComponent],
imports: [FormsModule, ReactiveFormsModule, SharedModule, TranslateModule.forRoot(), RouterTestingModule],
providers: [
SpinningService,
FormBuilder,
TranslateService,
{ provide: Router, useValue: mockRouter },
{ provide: CustomItemService, useValue: mockCustomItemService },
{ provide: PageDataService, useValue: mockPageDataService },
{ provide: UserService, useValue: mockUserService },
{ provide: ActivatedRoute, useValue: mockActivatedRoute }
],
schemas: [NO_ERRORS_SCHEMA]
});
fixture = TestBed.createComponent(AddItemComponent);
cmp = fixture.componentInstance;
fixture.detectChanges();
});
it('Simple test', () => {
expect(true).toBeTruthy();
});
});
You should remove your routing mocks (mockRouter, mockActivatedRoute) since you already import RouterTestingModule, something like this:
describe('AddItemComponent: ', () => {
let cmp: AddItemComponent;
let fixture: ComponentFixture<AddItemComponent>;
let de: DebugElement;
let el: HTMLElement;
const mockCustomCardService = {
getItemDeliveryDate: () => Observable.empty(),
emitItemChanges: () => Observable.empty(),
};
const mockPageDataService = {};
const mockUserService = {};
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AddItemComponent],
imports: [FormsModule, ReactiveFormsModule, SharedModule, TranslateModule.forRoot(), RouterTestingModule],
providers: [
SpinningService,
FormBuilder,
TranslateService,
{ provide: CustomItemService, useValue: mockCustomItemService },
{ provide: PageDataService, useValue: mockPageDataService },
{ provide: UserService, useValue: mockUserService }
],
schemas: [NO_ERRORS_SCHEMA]
});
fixture = TestBed.createComponent(AddItemComponent);
cmp = fixture.componentInstance;
fixture.detectChanges();
});
it('Simple test', () => {
expect(true).toBeTruthy();
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With