【发布时间】:2021-09-30 22:39:28
【问题描述】:
我正在尝试解析一个大文件并使用 cypress 断言文件中不包含字符串。我想替换断言消息以保持我的日志干净。我试过这个: 我将内容包装如下:
cy.task('parsePdf', filePath)
.its('text')
.then(($txt) => {
cy.wrap($txt).as('content');
});
然后我尝试使用 Chai expect 断言这一点,并以两种结果相同的方式插入自定义消息:
第一:
cy.get('@content').should(($txt) => {
expect($txt).to.not.include(
'text that should not be in the content',
'Custom error message'
);
});
第二:
cy.get('@content').should(($txt) => {
expect($txt, 'Custom error message').to.not.include(
'text that should not be in the content');
});
结果:
Custom error message 预期 Full report content 不包括 text that should not be in the content。
我寻找的只是在失败中记录Custom error message。
预期:
Custom error message
【问题讨论】: