我正在尝试编写一个下拉测试用例
第一个测试用例正常运行。 但是对于第二种测试情况,我正面临错误
我尝试了方法 toContain(),toEqual()。但是没有运气。 下面是它的代码。
HTML
<p id="noResultFound" *ngIf="values.length === 0" class="k-popup filter-search-list">No Results Found</p>
Component.sepc.ts文件
[![it('should show "No Results Found" if options are not listed', () => {
const fixture = TestBed.createComponent(SearchSelectComponent);
const comp = fixture.componentInstance;
comp.show = true;
comp.values = \[\];
comp.field = 'SearchList';
comp.placeholder = "search for company";
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(comp.values).toEqual(\[\])
//getting error at below line
expect(compiled.querySelector('#noResultFound').textContent).toMatch('No Result Found');
});