dgarlitt / karma-nyan-reporter

Nyan Cat style reporter based on the Mocha version
MIT License
169 stars 19 forks source link

"[object Object]" is printed instead of runtime errors #41

Open prantlf opened 6 years ago

prantlf commented 6 years ago

If the tests fail with a severe error , like requiring a non-existing script, or by a syntax error in a script, the error is not printed correctly. It is an object and after applying toString to it, even the cat cannot improve the useless output ;-)

HeadlessChrome 0.0.0 (Linux 0.0.0)
[object Object]

For example, if JSON.stringify were applied to it to get the full object printed, it would look like this:

HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR
{
  "message": "Uncaught Error: 'expect' was used when there was no current spec,...",
  "str": "Uncaught Error: 'expect' was used when there was no current spec, ..."
}

As long as the object structure is known, if object.message is defined, the message can be printed right away:

HeadlessChrome 0.0.0 (Linux 0.0.0) ERROR
Error: 'expect' was used when there was no current spec,...