unexpected
unexpected copied to clipboard
Improve standard error message wrapping
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.
Could take advantage of https://github.com/sunesimonsen/magicpen/issues/17 :)
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 thanks.