Skip to content

Allow custom validation function for reject  #106

@kanongil

Description

@kanongil

The new await reject that helps test promise rejections only supports two specific validation methods on the returned error.

It would be much more useful, if it can support additional custom validation, either through a callback, or by returning the error.

Example:

await expect(somePromise).to.reject((err) => {

    expect(err.isBoom).to.exist();
});

Alternatively:

const err = await expect(somePromise).to.reject();
expect(err.isBoom).to.exist();

This mode looks cleaner, but is a bit weird, since it requires reject to resolve with the error.

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions