Skip to content

Test runner naively rethrows non-testing error without preserving stack trace #44611

Closed
@timmolendijk

Description

@timmolendijk

Version

v18.8.0

Platform

Darwin Tims-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000 arm64

Subsystem

test runner

What steps will reproduce the bug?

The following line of code in the test runner harness rethrows an error if it is not coming from a test:

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.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions