unexpected icon indicating copy to clipboard operation
unexpected copied to clipboard

Improve standard error message wrapping

Open sunesimonsen opened this issue 9 years ago • 3 comments

When you have a narrow output width, in this case 50, chained assertions are not wrapped:

expect(
  [[1,2],[3,4]],
  'to have items satisfying',
  'to have items satisfying',
  'to be greater than or equal to', 2
)

You get:

expected [ [ 1, 2 ], [ 3, 4 ] ]
to have items satisfying to have items satisfying to be greater than or equal to 2

[
  [
    1, // should be greater than or equal to 2
    2
  ],
  [ 3, 4 ]
]

But it should have been:

expected [ [ 1, 2 ], [ 3, 4 ] ]
to have items satisfying
to have items satisfying
to be greater than or equal to 2

[
  [
    1, // should be greater than or equal to 2
    2
  ],
  [ 3, 4 ]
]

If we can't fit it within the line we should wrap on each assertion.

sunesimonsen avatar May 04 '16 20:05 sunesimonsen

Could take advantage of https://github.com/sunesimonsen/magicpen/issues/17 :)

papandreou avatar May 05 '16 22:05 papandreou

Added your example as a failing test: https://github.com/unexpectedjs/unexpected/tree/fix/adaptErrorMessageToPreferredWidth

Should be possible to hack something together in createStandardErrorMessage.js.

papandreou avatar May 05 '16 22:05 papandreou

@papandreou thanks.

sunesimonsen avatar May 06 '16 07:05 sunesimonsen