The documentation indicates that starting from Deno 1.21, deno test has been improved to filter out stack frames that are coming from Deno’s internal code and show the line of code where the error originates. This means that the stack traces for thrown errors in tests should now be more informative and focused on the user's code rather than internal Deno code.
Here's an example from the documentation showing the improved error reporting:
$ deno test test.ts
Check file:///dev/deno/test.ts
running 1 test from ./test.ts
error in a test ... FAILED (5ms)
failures:
./test.ts > error in a test
Error: boom!
throw new Error("boom!");
^
at file:///dev/deno/test.ts:2:9
failures:
./test.ts
error in a test
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out (15ms)
error: Test failed
As you can see, the stack trace is concise and points directly to the user's code where the error was thrown.
The documentation does not mention a way to tune the number of lines emitted from the test ERRORS section or a method to truncate stack traces based on files in a specific directory like Deno.cwd(). However, the improvements made should already provide a better testing experience by focusing on the user's code.
If you find that the stack traces are still not providing enough context for debugging, it might be worth providing feedback to the Deno team as they have expressed interest in further improving the test reporter in future releases. 🦕