bats-core/bats-assert

Print colorful diff between actual output and an expected output on test failure via smth like colordiff

EmilyGraceSeville7cf opened this issue · 1 comments

It's really hard to detect the difference between actual and expected output right from the bats message when the test fails. Because bats doesn't indicate what the difference between expectation and real result:

image

Such a message doesn't really show what should be changed to make the test pass.

This issue is transferred from this repository.

A colorful diff seems a bit difficult as all failure output is supposed to be red. Looks like adding the output of just diff already seems to be helpful. This quick hack (probably not in bats' coding style) helps me to spot the differences in the expected and actual output. Apply this patch on assert_output.bash:

189a190
>       ( \
192c193,196
<       'actual'   "$output" \
---
>       'actual'   "$output"
>       echo "Diff:"
>       diff <(echo "$expected") <(echo "$output")
>       )\