首页 > 解决方案 > 使用 Jasmine 进行角度的 Kendo-dropdown 单元测试

问题描述

我正在尝试使用 Jasmine/Karma 在我的 Angular 应用程序上运行集成测试。我们主要在应用程序中使用剑道控件。在编写测试套件来测试剑道下拉组件时,我无法在规范文件中获取剑道下拉控件的引用。非常感谢您的帮助。

TestBed.configureTestingModule({
      declarations: [ XXXX,YYYY,ZZZZ],
      imports:[HttpClientModule,RouterTestingModule,FormsModule ,ReactiveFormsModule ],
      providers:[ WebApiService,YYYY,ZZZZ],
    })
    .compileComponents();

beforeEach(() => {
    fixture = TestBed.createComponent(CreateCustomerComponent);
    component = fixture.componentInstance;
    datePipe=new DatePipe("en-US");
    fixture.detectChanges();
  });

it('#should the length of dropdown is greater than one',()=>{
    const trigger = fixture.debugElement.query(By.css('#dropDownId')).nativeElement;
    expect(trigger).toBeTruthy();
   
  });

html
<kendo-floatinglabel
  [text]="Customer"
>
  <kendo-dropdownlist
    [id]="'dropDownId'"
    [data]="DataItems"
    [textField]="'DataText'"
    [valueField]="'DataValue'"
    [(ngModel)]="selectedItem"
    
  >
  </kendo-dropdownlist>

</kendo-floatinglabel>

由于触发器变量中的未定义值,测试正在中断。

标签: angularkendo-dropdownkendo-angular-ui

解决方案


推荐阅读