angular - 赛普拉斯测试中的 Angular getHarness 不起作用
问题描述
我目前正在尝试启动和运行组件测试,并与角线束作斗争。在我的测试中,我想使用 MatPaginatorHarness(但我对它们都有同样的问题),但不幸的是 async/await 方法在 cypress 中不起作用。所以我用 Promise 试了一下。现在我收到以下错误:
Cypress detected that you returned a promise from a command while also invoking one
or more cy commands in that promise.
The command that returned the promise was:
> cy.get()
The cy command you invoked inside the promise was:
> cy.log()
Because Cypress commands are already promise-like, you don't need to wrap them or return your own promise.
代码是:
it('shows opens paginator', () => {
const data: StudyStateModel[] = thirteenRows;
const fixture = mount(DatatableComponent, {
tableCols: TableColsConfig.STUDIES_COLS,
tableData: data,
activeEndpoint: apiEndpoints.STUDY
});
const loader = TestbedHarnessEnvironment.loader(fixture);
loader.getHarness<MatPaginatorHarness>(MatPaginatorHarness).then((paginator) => {
paginator.setPageSize(10);
fixture.detectChanges();
cy.get('.mat-row').should('have.length', 10);
cy.get('.mat-row').should('not.be.visible');
fixture.detectChanges();
console.log(paginator);
paginator.setPageSize(25);
fixture.detectChanges();
});
我知道我不应该使用承诺,因为赛普拉斯在这里告诉我,但我不知道该怎么做。只有在 promise 中有 cy.get 函数时才会出现问题。但我需要它们,因为我需要使用分页器。先感谢您。
解决方案
推荐阅读
- html - 如何修复表单中嵌套容器顶部的按钮
- node.js - 为什么客户端的进程已经被杀死,服务器close_wait可以清空
- django - 如何在大型代码库中找到 Django 中相关名称的来源?
- javascript - 数组中 JavaScript 展开语法的时间复杂度是多少?
- azure - 使用 Azure Pipeline 时如何将文件复制到 Azure Blob
- eclipse - eclipse调试视图安排代码调试
- java - Jasper 报告具有来自路径的命名样式引用的连续样式
- flutter - 没有为类定义构建上下文
- angular-material - 如何主题化角材料组件形状?
- python - 如何让 tkinter 与 matplotlib checkbutton 集成以更改变量?