如何解决抛出object ErrorEvent的问题,请大家指教。当我为特定方法编写测试用例时,在调试方法调用的过程中,我找不到抛出对象ErrorEvent的位置。
我得到了像这样的错误
Chrome 68.0.3440 (Windows 10 0.0.0): Executed 19 of 19 (2 FAILED) DISCONNECTED (1 min 7.294 secs / 0 secs)
Chrome 68.0.3440 (Windows 10 0.0.0) ERROR
{
"message": "An error was thrown in afterAll\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown",
"str": "An error was thrown in afterAll\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown\n[object ErrorEvent] thrown"
}
发布于 2018-08-17 01:44:54
我也遇到过类似的问题,在我的开发工具中检查控制台给了我更多关于这个错误的信息。加入这个标志可能也会有所帮助:
--source-map=false
发布于 2019-03-26 01:19:34
在我发现之后,我想我们应该在karma.conf.js.中设置browsers: ['Chrome']
和singleRun: false
然后运行所有测试用例,打开Chrome浏览器控制台,查看错误。这样,您就可以找到问题的根本原因。这个把戏对我很管用。我希望这个技巧对你有效。
发布于 2018-08-20 23:39:30
我绝对同意@Dan的回答-但是如果你已经在运行测试,你也可以使用开发人员工具Javascript调试器来单步执行代码来发现问题。
我通常会发现错误是在测试组件的构造函数或ngOnInit方法中取消引用未定义的对象。运行时不使用source-map,也可以调试
https://stackoverflow.com/questions/51823981
复制相似问题