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

Rejecting a promise with an object gives a blank failure #1532

Closed
jakecraige opened this issue Feb 4, 2015 · 3 comments
Closed

Rejecting a promise with an object gives a blank failure #1532

jakecraige opened this issue Feb 4, 2015 · 3 comments
Labels
type: bug a defect, confirmed by a maintainer

Comments

@jakecraige
Copy link
Contributor

If a promise is rejected with a normal javascript object the test still fails, but with a blank message. This confused me for the longest time.. It would be great if we could have it at least JSON.stringify the object or alert the user that they should return an Error object like it does if you resolve with a string.

Test case to reproduce plus show current behavior using RSVP promise library:

var RSVP = require('rsvp');

it('gives helpful message when rejected with string', function() {
  return RSVP.reject('an error message');
});
// => Error: the string "an error message" was thrown, throw an Error :) ... stack

it('gives helpful message when rejected with error', function() {
  return RSVP.reject(new Error('an error message'));
});
// => Error: an error message ... stack

it('gives blank message and no stack when rejected with object', function() {
  return RSVP.reject({});
});
// => nothing
@dasilvacontin
Copy link
Contributor

Confirmed.

@dasilvacontin dasilvacontin added type: bug a defect, confirmed by a maintainer status: accepting prs Mocha can use your help with this one! labels Feb 4, 2015
jakecraige added a commit to jakecraige/mocha that referenced this issue Feb 6, 2015
@dasilvacontin
Copy link
Contributor

Closed via #1537.

@boneskull
Copy link
Member

@dasilvacontin @jakecraige

Sorry I didn't see this earlier. Please see my comment here.

jakecraige added a commit to jakecraige/mocha that referenced this issue Feb 9, 2015
@boneskull boneskull removed the status: accepting prs Mocha can use your help with this one! label Oct 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants