2
我不明白我在做什麼錯,我沒有找到任何鏈接RouterLinkWithHref任何測試錯誤,此外我'米不使用RouterLinkWithHref任何地方,據我所知:/角度測試錯誤:無法讀取未定義的屬性「訂閱」在新的RouterLinkWithHref
誰能幫我這個:
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();
});
});
我遇到了同樣的事情,我在嘲笑'像你router'在這裏做一個組成部分,在那裏我有一個''標籤與在該routerLink屬性標記。看看'RouterTestingModule'。這可能也有幫助:https://stackoverflow.com/a/40187305/4530745 – nickflynn
你找到一個解決方案嗎?我目前遇到同樣的問題.. – Nicholas
不,我沒有,對不起。 – Donovant