Skip to content

Feature request: toThrow() / toBeRejected() should return the objects thrown / rejected with #289

@dhardtke

Description

@dhardtke

It would be neat if we could do the following:

const rejectedWith = await expect(Promise.reject(new CustomError('foo', {myProp: 42, count: 2})))
  .toBeRejectedWith(CustomError) as CustomError;
expect(rejectedWith.myProp).toEqual(42);
expect(rejectedWith.count).toBeGreaterThan(1);

The same is true for toThrow().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions