litixsoft / karma-mocha-reporter

Karma reporter plugin with mocha style logging.
Other
197 stars 45 forks source link

String diffs JSON-encoded #61

Closed developit closed 8 years ago

developit commented 8 years ago

Hi there,

It would appear that the recently released String diffing support diffs JSON-encoded strings. This seems unintentional.

Here is a reproduction:

expect(`a
b`).to.eql(`b
a`);

The above produces this output:

Since this appears to be JSON-encoded, I tried manually parsing the expected and actual values around line 369:

err.actual = JSON.parse(err.actual);
err.expected = JSON.parse(err.expected);

With this in place, the output is correct:

Is it possible that somewhere within the chai -> mocha -> karma -> karma-mocha-reporter stack, something is stringifying the actual and expected properties?

developit commented 8 years ago

Submitted a PR for the fix that worked for me, though I can't be sure it's universally workable.