我写了一个包含多个范围的测试用例。现在,如果文本不正确或值错误或等待时间过长,则其中一个测试用例可能会失败。通常,如果出现这种情况,它将显示失败。但是我想处理这些错误,以便用户可以收到一条消息而不是错误。我已经尝试过以下方式。但是它没有捕获任何错误。它总是会然后阻止。期望中,我写了一条错误的消息,这样我可以被抓住,但没有任何正常工作。
这是我的代码
修改后的代码
it('save button is clicked and Save notification is appeared', async () => {
await click.onto(ContentPage.saveEdit);
// I want to wait here
ContentPage.saveNotification.isPresent().then(async function() {
await expect(ContentPage.saveNotification.getText()).toContain('0030565002C0 Updated.')
}).catch(function (err) {
console.log(err)
});
});
答案 0 :(得分:0)
茉莉花提供任何期望的可选消息
toContain(expected: T, expectationFailOutput?: any): Promise<void>;