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

Expect to throw (number) doesn't seem to work #1070

Closed
SamStonehouse opened this issue Oct 27, 2017 · 3 comments
Closed

Expect to throw (number) doesn't seem to work #1070

SamStonehouse opened this issue Oct 27, 2017 · 3 comments

Comments

@SamStonehouse
Copy link

const failingCall = function() {
  throw 10;
};

expect(failingCall).to.throw(10);

Results in 'AssertionError: expected [Function: failingCall] to throw 10 but 10 was thrown'

const failingCall = function() {
  throw 'test';
};

expect(failingCall).to.throw('test');

Passes as normal

And...

const failingCall = function() {
  throw 0;
};

expect(failingCall).to.throw(0);

Fails with 'AssertionError: expected [Function: failingCall] to throw an error'

@keithamus
Copy link
Member

Hey @SamStonehouse thanks for the issue.

This seems to be a problem with our type checking for that assertion. We should throw a better error message saying that throw(instanceof Number) is not supported.

PRs welcome 😄

@bryanbraun
Copy link

I put together a PR for this issue over at #1071. Let me know if you have any feedback.

@keithamus
Copy link
Member

Hey @SamStonehouse thanks for the issue.

We've added this to our Roadmap https://github.com/chaijs/chai/projects/2! We'll be releasing chai 5 soon, but for now I'll close this issue because it is tracked on our roadmap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants