Skip to content

[Feature]: show full error or object in promised expect #14750

Open
@piranna

Description

@piranna

🚀 Feature Proposal

When using expect(promise).resolves or expect(promise).rejects, and having the opposite resolution than expected, only the error message or the type of the value are being shown, hidding information. OTOH, if awaiting the Promise object and fails, full exception with its trace is being shown. I think expect(promise) should show the full error with exception or the original value instead if receiving an unexpected resolution.

Motivation

Easier debugging, being able to have the original error object with the additional Promise related info details provided by expect(promise).

Example

No response

Pitch

Capture of failed Promises is already being done by Jest, I just only have the same behaviour when using expect(promise). Since it's returning a Promise itself, probably would make sense to put the original failed one in the cause field of the exception.

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