观看控制台的错误
我有一个使用帆布元素的应用程序,该应用程序很难用JavaScript测试,但确实将消息传递给控制台。
我如何观看写在控制台上的错误?
我尝试修补窗户控制台,但它不起作用。
const messages = []
window.console.error = (msg) => {
messages.push(msg)
})
// actions causing error
expect(messages.length).to.eq(0)
I have an app using canvas elements, which are difficult to test with javascript but it does throw messages to the console.
How can I watch for errors written to the console?
I tried monkey patching the window console, but it's not working.
const messages = []
window.console.error = (msg) => {
messages.push(msg)
})
// actions causing error
expect(messages.length).to.eq(0)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用柏树
cy.spy()
,ref docsYou can watch console messages with Cypress
cy.spy()
, ref docs