Exception 如何在测试Cafe错误中获取完整堆栈跟踪
我一直在使用TestCafe编写一个内部测试框架,其中操作(t.click)和断言(t.expect)不是直接写入规范中,而是在其他文件中定义和聚合 在测试没有失败之前,一切都很酷:在本例中,test Cafe reporter在控制台中编写断言/操作失败以及相关的代码片段,但我没有找到理解从测试到失败断言的函数调用的完整堆栈跟踪的方法 如何确保在reporter中提供完整的堆栈跟踪,记录堆栈跟踪以及导致测试失败的所有函数调用 我知道原因应该与以下方式有关:错误的堆栈跟踪只显示最后执行的等待,而不是所有以前的调用Exception 如何在测试Cafe错误中获取完整堆栈跟踪,exception,automated-tests,stack-trace,e2e-testing,testcafe,Exception,Automated Tests,Stack Trace,E2e Testing,Testcafe,我一直在使用TestCafe编写一个内部测试框架,其中操作(t.click)和断言(t.expect)不是直接写入规范中,而是在其他文件中定义和聚合 在测试没有失败之前,一切都很酷:在本例中,test Cafe reporter在控制台中编写断言/操作失败以及相关的代码片段,但我没有找到理解从测试到失败断言的函数调用的完整堆栈跟踪的方法 如何确保在reporter中提供完整的堆栈跟踪,记录堆栈跟踪以及导致测试失败的所有函数调用 我知道原因应该与以下方式有关:错误的堆栈跟踪只显示最后执行的等待,而
<section> ... </section>
<section class="section--modifier">
<h1> ... </h1>
<div>
...
<button class="section__button">
<div class="button__label">
<span class="label__text">Hello!</span> <-- Target of my test
</div>
</button>
...
</div>
</section>
<section> ... </section>
但在《记者》中,我没有证据表明由于以下一连串的呼叫而失败
- await verifyButtonColor(t, MyButton1, 'green');
- await verifyLabelColor(t, MyLabel, expectedColor);
- await t.expect(color).eql(expectedColor, `Color should be ${expectedColor}, found ${color}`);
有没有人面临过类似的问题
另一种方法是记录导致失败的选择器的“路径”,但在测试Cafe文档时,我没有发现这样做的可能性:知道断言在具有以下路径的元素上失败至少有助于理解出错的原因
.section--modifier .section__button .button__label .label__text
本主题与TestCafe提案相关:
与此同时,您可以尝试一下这个报告器:或者您可以开发自己的显然,自定义报告器也没有从引擎接收到足够的信息来改进这些堆栈跟踪(请参阅您链接的错误报告上的)。
//
// Definition of assertion verifyLabelColor (label.js)
//
export async function verifyLabelColor(t, node, expectedColor) {
const MyText= node.find('.label__text');
const color = await MyText.getStyleProperty('color');
await t.expect(color).eql(expectedColor, `Color should be ${expectedColor}, found ${color}`); // <-- it will FAIL!
}
...
await t.expect(color).eql(expectedColor, `Color should be ${expectedColor}, found ${color}`);
...
- await verifyButtonColor(t, MyButton1, 'green');
- await verifyLabelColor(t, MyLabel, expectedColor);
- await t.expect(color).eql(expectedColor, `Color should be ${expectedColor}, found ${color}`);
.section--modifier .section__button .button__label .label__text