Ron*_*hen 2 karma-jasmine angular-material2 angular angular7
使用Angular 7我将材质表添加到我的应用程序中 ng generate @angular/material:table test-table
在生成的模板内有一个分页器:
<mat-paginator #paginator
[length]="dataSource.data.length"
[pageIndex]="0"
[pageSize]="50"
[pageSizeOptions]="[25, 50, 100, 250]">
</mat-paginator>
Run Code Online (Sandbox Code Playgroud)
在初始化时,数据源已更改:
ngOnInit() {
this.dataSource = new ItemsTableDataSource(
this.paginator,
this.sort,
this.route.paramMap,
this.afs
);
}
Run Code Online (Sandbox Code Playgroud)
尝试在Karma上编译组件时,expect(component).toBeTruthy();出现以下错误
Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has
changed after it was checked. Previous value: 'length: 0'. Current
value: 'length: 1'.
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
小智 5
不知道它是如何洁净的,但就我而言,我只是从规格文件中删除了“ fixture.detectChanges()”调用。我正在使用A6 ReactiveForm,在测试中设置一些初始虚拟日期范围值。表单工作正常,但测试失败并显示您的错误。
| 归档时间: |
|
| 查看次数: |
1201 次 |
| 最近记录: |