How to resolve [object ErrorEvent] thrown for karma testing in Angular 6

uncaught [object object] thrown karma
errorevent angular
karma executed 0 of 0 error angular 6
angular test error thrown
error properties: object({ ngsyntaxerror: true })
angular integration testing
angular unit test service
unit testing angular components

How to solve [object ErrorEvent] thrown, please suggest anyone. When I am writing a test case for specific methods, during the time of debugging method call is going but I am unable to find where [object ErrorEvent] thrown coming.

I am getting like this error

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"
  }

I've had a similar issue and checking the console in my dev tools gave me a lot more info about the error. Throwing in this flag might help too:

--source-map=false

[object ErrorEvent] thrown in angular app, Debug window. · Issue , [object ErrorEvent] thrown in angular app, Debug window. #2852. Closed test-​config/karma-test-shim.js', watched: true }, { pattern: '. It doesn't appear that newer versions of @angular/cli (e.g. 6.0. Update source-map-support to 0.5.9 to resolve issue with source maps for karma runs (ng test) in v1.7. I’m pretty sure when you’ve already come across this exception: `[object ErrorEvent] thrown` when you execute your Karma tests in an Angular project. Not very helpful, right? Let’s take a look how to get more a more useful info and finally resolve it.

After my findings, I figure out that we should set browsers: ['Chrome'] and singleRun: false in karma.conf.js. Then run all the test cases and open Chrome browser console and see the error. This way you will reach out the root cause of the problem. This trick worked for me. I hope this trick works for you.

[object ErrorEvent] thrown · Issue #2881 · karma-runner/karma · GitHub, I am getting below error, object ErrorEvent thrown jasmine if i try to run individual angular karma & jasmine version : Plz help me to resolve this issue When you run your tests you will see the ErrorEvent object printed by  What about ng test –single-run? July 6, 2018 August 5, 2018 djagielo I was writing about the similiar problem in case of Angular v4 in the post named How to debug ‘NetworkError: Failed to execute ‘send’ on ‘XMLHttpRequest” in Karma tests .

I definitely agree with the answer from @Dan - but if you're already running the tests you can also use the developer tools Javascript debugger to step through the code to find the issues as well.

I've usually found the error is dereferencing an undefined object in the constructor or ngOnInit method in the component under test. Either running without source-maps, or debug

"[object ErrorEvent] thrown" error in my Karma/Jasmine tests?, For angular-cli 6, --sourceMap=false seems to work. – skermajo May 11 '18 For me it was related to having a promise resolved in the ngOnInit of a component. I had to use Angular - How to unit test component with asynchronous service call If I replace it with 0 , [object ErrorEvent] thrown goes away. object errorevent thrown karma angular 6 (11) 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.

Angular 6, problem in case of Angular v4 in the post named How to debug 'NetworkError: Failed to execute 'send' on 'XMLHttpRequest” in Karma tests. Dismiss Join GitHub today. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

[object ErrorEvent] thrown by Karma in Angular Unit Tests, So I was executing my Angular unit tests and all of a sudden the following error message popped up. Here's a screenshot of it. Read More. Subscribe to our  The angular-cli configuration of karma uses the file “test.ts” as the entry point of the tests for the application. Let’s take a look to that file; We have a lot of things going on here.

Debugging [object ErrorEvent] in Angular Unit Tests, So you've started unit testing your angular app and you get these crazy errors [​object ErrorEvent] thrown. Gee, what a useful error message. johnjbarton changed the title Test passes in command line but fails in debug [object ErrorEvent] thrown in angular app, Debug window. Oct 24, 2017 This comment has been minimized.

Comments
  • Thanks a lot .means you are telling need to run like this ng test --source-map=false in console
  • Yup, that'd be it. But also in your Karma.conf.js set browsers:['Chrome'] and singleRun: false so it'll run in a browser window and you can look at the console error there. Might help.
  • what is we are using browsers: ['phantomJS'] and error still persist.
  • @Irrfan23 phantomJS is good for headless browsers, but for debugging issue you need to change the "browsers" from phantomJS to Chrome for checking the error in console. After watching the error you change it back to phantomJS again!
  • the test which is working fine in chrome browser, after chnaging browser to phantomJS its showing error. something different.
  • @Irrfan23 What errors does it shows, can u paste it here?