Ruf*_*eng 6 unit-testing angular-material angular
我正在开发一个项目,我们的测试是使用 Angular 的 Harnesses 进行的,扩展ComponentHarness类。我正在测试一个表,并希望根据行确定一些元素的范围。例如,我想从第一行提取按钮。我找不到一种方法让所有按钮的范围仅限于第一行。这是我到目前为止得到的
export class ProductComponentHarness extends ComponentHarness {
static readonly hostSelector = 'my-selector-component';
private readonly table = this.locatorFor(MatTableHarness);
async getRows(): Promise<MatRowHarness[]> {
const tableResolved = await this.table();
return tableResolved.getRows();
}
async getAllButtonsFromFirstRow(): Promise<void> {
const firstRow = (await this.getRows())[0];
// Stuck here, how to scope?
this.locatorForAll(firstReleaseRow, MattButtonHarness); // My logic pointed me here first time
this.locatorForAll(MatButtonHarness.with({ ancestor: firstRow })); //Not working
}
}
Run Code Online (Sandbox Code Playgroud)
也许方法不正确?我找不到更多关于具有 Material Angular 的嵌套线束的信息。最坏的情况我只是提取所有按钮并从那里进行检查,但我想学习如何正确确定范围,如果在任何时候我发现类似的情况
| 归档时间: |
|
| 查看次数: |
851 次 |
| 最近记录: |