How do I debug a “[object ErrorEvent] thrown” error in my Karma/Jasmine tests?

后端 未结 17 2295
生来不讨喜
生来不讨喜 2020-12-04 09:51

I have several failing tests that only output [object ErrorEvent] thrown. I don\'t see anything in the console that helps me pinpoint the offending code. Is t

17条回答
  •  离开以前
    2020-12-04 10:04

    I was using a proxy in my application defined in proxy.conf.json like:

    '/api': { 'target': 'some path', 'changeOrigin': false }
    

    Because Karma wasn't aware of this proxy, it kept trowing errors in the console that the API endpoint could not be found. So after looking in the Karma documentation, I found out that what I could do was to add the "proxies" property in karma.conf.js with the same object from the proxy.conf.json:

    proxies: { '/api': { 'target': 'some path', 'changeOrigin': false }}
    

    The error in the console was gone, and the [object errorEvent] was no longer thrown.

提交回复
热议问题