Include stack trace in failed test info
I opened an issue on the Gleam repository about a potential inconsistency in how let assert failures are reported (issue 4703). The behavior differs between gleam run and gleam test.
Here’s an example of the output from gleam test:
test/phone_number_test.gleam
test: cleans_the_number_test
error: Pattern match failed
site: phone_number:9
value: ["2", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
And from gleam run:
runtime error: let assert
Pattern match failed, no pattern matched the value.
unmatched value:
["0", "0", "0", "0", "0", "0", "0", "0", "0", "0"]
stacktrace:
phone_number.-clean/1-fun-0- src\phone_number.gleam:9
As I noted in the issue:
“It seems like
gleam runis much more explicit—it clearly signals that the developer made a wrong assertion, with a red-colored title and a full stack trace (e.g., src\phone_number.gleam:9). On the other hand,gleam testreports the failure more subtly, almost as if everything ran normally.”
Wouldn’t it be a good idea for gleam test to adopt a stricter and more visible approach to let assert failures—similar to gleam run—since these are developer errors that benefit from being highlighted clearly?
Adding the stack trace sounds good!
The behavior differs between gleam run and gleam test.
There's no expectation for these two distinct projects to have the same output.