You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Test runner naively rethrows non-testing error without preserving stack trace #44611
In the process err.stack is lost, while this is crucial information for understanding what went wrong.
How often does it reproduce? Is there a required condition?
I am not familiar enough with the test runner’s architecture, but I think this is relevant in scenarios where the code that throws the original error runs in a timer such as setInterval.
What is the expected behavior?
The test runner’s stdout includes the original error’s stack trace.
What do you see instead?
The test runner only displays the stack trace of the rethrown error, which isn’t very helpful.
When the code that is being tested crashes, either the code is broken or the test is broken (or both). You want to then be able to debug this with full information. Currently the test runner catches non-testing errors and strips them of their stack trace. This makes debugging unnecessarily hard.
So in other words: I expect a test runner to give me (at least) the same information about what’s going wrong with my code as I am given when I run my code directly (without a test runner).
I expect a test runner to give me (at least) the same information about what’s going wrong with my code as I am given when I run my code directly (without a test runner).
I haven't been able to reproduce the issue, could you provide some example code?
This code appears to retain the stack trace in the test runner output:
Thanks, I can reproduce this. Because this does not seem to happen when removing the test runner boilerplate, I am assuming it is indeed a bug in the test runner.
Activity
MoLow commentedon Sep 12, 2022
why isn't this expected?
timmolendijk commentedon Sep 12, 2022
When the code that is being tested crashes, either the code is broken or the test is broken (or both). You want to then be able to debug this with full information. Currently the test runner catches non-testing errors and strips them of their stack trace. This makes debugging unnecessarily hard.
So in other words: I expect a test runner to give me (at least) the same information about what’s going wrong with my code as I am given when I run my code directly (without a test runner).
tniessen commentedon Sep 12, 2022
I haven't been able to reproduce the issue, could you provide some example code?
This code appears to retain the stack trace in the test runner output:
[-]Test runner naively rethrows error without preserving stack trace[/-][+]Test runner naively rethrows non-testing error without preserving stack trace[/+]timmolendijk commentedon Sep 12, 2022
tniessen commentedon Sep 12, 2022
Thanks, I can reproduce this. Because this does not seem to happen when removing the test runner boilerplate, I am assuming it is indeed a bug in the test runner.
test_runner: include stack of uncaught exceptions
test_runner: include stack of uncaught exceptions
test_runner: include stack of uncaught exceptions
test_runner: include stack of uncaught exceptions
test_runner: include stack of uncaught exceptions
test_runner: include stack of uncaught exceptions
fix: include stack of uncaught exceptions
fix: include stack of uncaught exceptions
fix: include stack of uncaught exceptions