如何在SoftAssertall上应用期望或在测试结果中显示出明确性(错误:预期对象为函数)
我正在使用'soft-assert'库( soft-assert library )在我的测试步骤上断言,如果其中任何一个失败,则没有停止测试。
根据文档,通过使用SoftAsserTall()命令在测试结束时验证了所有软安置。而且这很好。但是,如果什么都没有失败,我在测试结果中看不到任何明确的消息,就像我使用Expect Command时一样。
因此,如下所示,我正在尝试通过SoftAssertall()命令应用期望,但是我收到了错误消息: “预期{object(userInvocationstack,specwindow,...)}成为函数”
我想做的是什么:
expect(cy.softAssertAll()).not.throw(Error)
有人知道我该如何执行此操作或在下图下图中解决错误? 提前致谢。
I'm using 'soft-assert' library (soft-assert library) to apply assertion on my test steps without stopping the test if any of them fail.
According to the documentation, all soft-assert is verified at the end of the test by using softAssertAll() command. And this works very well. However, if nothing fails, I don't see any explicit message in my test result as when I use expect command.
So, I'm trying to apply expect over the softAssertAll() command, as it's seen below, but I'm getting the error message:
"expected { Object (userInvocationStack, specWindow, ...) } to be a function"
What I'm trying to do:
expect(cy.softAssertAll()).not.throw(Error)
Does anyone know how can I do this or solve the error in the image below?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参见chai示例
请参见 throw 请注意,请注意您通过, 。函数名称 而无需调用。我认为这使Chai可以在尝试键入中包装功能调用并优雅地报告故障。
您不能使用柏树自定义命令做同样的事情,因为它不会像上面的
badfn
相同的方式引起错误。在内部,它吞没了任何错误,并将测试状态设置为“失败”。您可以合理地期望这是有效的
,但是
jsonassertion
中存在内部错误,似乎与此类中的
参考有关。要修复,使用箭头函数
或较短
检查diff数组,
这更清洁,更清晰
See the Chai example for throw
Note you pass in the function name without invoking it. I think this allows chai to wrap the function invocation in a try-catch and gracefully report the failure.
You can't do the same with a Cypress custom command as it will not raise errors in the same way as
badFn
above. Internally it swallows any error and sets the state of the test to "failed".You could reasonably expect this to work
however there's an internal error in
jsonAssertion
that seems to be related to thethis
reference inside it's class.To fix, use an arrow function
or shorter
Check the diff array
This is cleaner and clearer