Skip to content

[Feature]: Support Error.prototype.cause #13260

Closed as not planned
Closed as not planned
@silverwind

Description

@silverwind

🚀 Feature Proposal

Some new APIs like fetch make use of Error.prototype.cause which jest does not display at all for thrown errors, which makes debugging these errors harder than necessary.

Motivation

It will make errors with cause easier to debug.

Example

test("cause", () => {
  try {
    throw new Error("cause");
  } catch (err) {
    throw new Error("wrapped", {cause: err});
  }
});

Will output only the wrapped error message, which is often unhelpful:

 FAIL  ./test.js
  ● cause

    wrapped

It'd be better if the cause message would also be shown:

 FAIL  ./test.js
  ● cause

    wrapped
    cause

Pitch

Because Error.prototype.cause is a standard Javascript feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions