chai - 如何在柴期望中给出两个目标?
问题描述
我的量角器测试中有以下代码,
async function canSeeLoanPage(): Promise<void> {
const header1 = element(by.tagName('h1')).getText();
const header2 = element(by.css('section h1')).getText();
try {
await expect(header1).to.eventually.equal('Your Name');
} catch (e) {
await expect(header2).to.eventually.equal('Your Name');
}
}
而不是检查一个try catch,像这样给出两个目标的正确方法是什么?
await expect(header2,header2).to.eventually.equal('Your Name');
解决方案
我不知道比简单地使用两行代码更好的方法:
await expect(header1).to.eventually.equal('Your Name');
await expect(header2).to.eventually.equal('Your Name');
为什么需要 try catch 块?
推荐阅读
- javascript - 在 OOP Javascript 中锁定特权方法
- r - 基本数据框程序
- javascript - 如何在 html5 / ionic 中使用平方米或平方公里
- r - origRenderFunc() 中的警告:
- c - strcmp 字符串以换行符结尾
- pandas - 在 Pandas 中为每列创建摘要行
- visual-studio - 什么设置控制 Visual Studio 2017 中的自动关闭引号行为?
- html - Bootstrap 响应式表格水平滚动始终可见
- ios - 以编程方式设置 Storyboard ID
- php - PHP - 文件所有权/权限问题 - 上传的文件在上传后无法访问/找不到