mocha
mocha copied to clipboard
Assertions that compare two numbers for equality are confusing
Maybe it's just me, but I find this presentation very confusing:
It takes me a few seconds to mentally parse that. The plus and minus characters throw me because they look like they're positive/negative numbers at first. (I get that it's standard diff formatting, but I don't think diff formatting is appropriate when comparing integers.) After that, you have to mentally link up the colours or the symbols to work out which way round the problem is.
Wouldn't something like this be much clearer:
AssertionError: should contain one changed file
expected: 1
actual: 2
(This could be just for when both the expected and actual values are numbers.)
+1 for better message. I too find it confusing +/- with numbers the expected: actual: is much clearer.
+1
+1 this has always sucked, good call
This will be a step in the right direction, but the tricky bit will be to filter out true strings and/or numbers from garbled stringified objects, like this one:
"[\n first-array-entry\n second-array-entry\n]"
I find both the order and colors confusing here. For a diff the convention is
-before
+after
so seeing as expected
is the "before" state and actual
is the "after" state, mocha's diff is backwards. Instead of
-actual
+expected
it should be
-expected
+actual
Per #5027, we're not looking to make any significant changes. A lot of folks are very used to the way Mocha renders things. Changing it up now would incur a whole bunch of user irritation.
Sorry folks - we're going to have to keep this as-is.