Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom validation function for reject #106

Closed
kanongil opened this issue Sep 17, 2017 · 1 comment
Assignees
Labels
Milestone

Comments

@kanongil
Copy link
Member

@kanongil kanongil commented Sep 17, 2017

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.

@hueniverse hueniverse self-assigned this Sep 17, 2017
@hueniverse hueniverse added the feature label Sep 17, 2017
@hueniverse hueniverse added this to the 5.0.1 milestone Sep 17, 2017
@hueniverse

This comment has been minimized.

Copy link
Member

@hueniverse hueniverse commented Sep 17, 2017

I had the same thought as I was rewriting the tests and had to use try...catch instead of an assertion where the test needed extra checks. I'll add this today. I'm going to go with the second.

jhakonen pushed a commit to jhakonen/code that referenced this issue Dec 5, 2018
jhakonen pushed a commit to jhakonen/code that referenced this issue Dec 5, 2018
jhakonen added a commit to jhakonen/code that referenced this issue Dec 5, 2018
jhakonen added a commit to jhakonen/code that referenced this issue Dec 5, 2018
hueniverse added a commit that referenced this issue Dec 15, 2018
Fix reject()'s documentation and add documentation for #106
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.