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

reject does not fail if argument is of the wrong type #119

ferrao opened this issue Nov 23, 2017 · 2 comments


Copy link

@ferrao ferrao commented Nov 23, 2017

I expected the following test to fail:

it('should fail', async () => {
        const promise = Promise.reject(new Error('some error message'));
        await expect(promise).to.reject(Error, {});
        await expect(promise).to.reject(Error, []);
        await expect(promise).to.reject(Error, null);
        await expect(promise).to.reject(Error, undefined);
        await expect(promise).to.reject(Error, NaN);


But surprisingly it does not. From the documentation, it is clear that the second argument to reject() needs to be a string or a regex, but would it not be safer to make the test fail if that is not the case?


This comment has been minimized.

Copy link

@cjihrig cjihrig commented Dec 7, 2017

Thanks for reporting this. I don't have the time to address this right now, but I'll take a PR to fix it.


This comment has been minimized.

Copy link
Contributor Author

@ferrao ferrao commented Dec 13, 2017

I have submitted a PR @cjihrig , can you review it please?

@cjihrig cjihrig closed this in #121 Jan 2, 2018
@cjihrig cjihrig self-assigned this Jan 2, 2018
@cjihrig cjihrig added this to the 5.1.3 milestone Jan 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.