我只想测试App.Component.html页面中是否有routeLink='/home'
可用。在Udemy的某个地方,我看到了一个关于如何测试routerLink的视频。我遵循了相同的步骤,但我不知道这是Visual Studio Code或角度测试中的其他问题。
注意:请务必阅读代码中的注释
测试如下,
it('AppPage should have a router link named home', async(() => {
let debugElements = fixture.debugElement.queryAll(By.directive(RouterLinkWithHref))
/*
Here visual studio code doesn't give me intellisense for findIndex method.
when I write 'x.', it doesn't give me intellisense for properties
but I checked in DOM that such properties property exists. What's wrong?
*/
let index = debugElements.findIndex(x=>x.properties['href']==='/home');
expect(index).toBeGreaterThan(-1);
}))
properties
属性存在,如此处所示,
但实际上我得到这样的错误,
有什么问题?