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

fix Runner#fail logic to seamlessly support Error-like objects. Closes #1677 #1678

Closed
wants to merge 3 commits into from

Conversation

igorraush
Copy link

No description provided.

@@ -202,10 +203,13 @@ Runner.prototype.fail = function(test, err) {
++this.failures;
test.state = 'failed';

if (!(err instanceof Error)) {
var isError = err instanceof Error;
var isErrorLike = err && isString(err.message) && isString(err.name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will throw an exception if err happens to be null. add additional checks.

I would also probably avoid creating the variables if we are not going to use them elsewhere.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boneskull Sorry, I fail to see how it will throw an exception when err is null :( This test passes for me:

it('should emit a helpful message when failed with null', function(done){
  var test = {}, err = null;
  runner.on('fail', function(test,err){
    err.message.should.equal('the null [null] was thrown, throw an Error :)');
    done();
  });
  runner.fail(test, err);
})

The message could definitely be more helpful, but no crash.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, n/m, I think I was reading the example in the original issue instead

@boneskull boneskull added status: waiting for author waiting on response from OP - more information needed pr-needs-work labels May 9, 2015
@jbnicolai jbnicolai force-pushed the master branch 3 times, most recently from 2f458ab to 2952eca Compare July 5, 2015 10:25
@igorraush igorraush closed this Sep 25, 2015
@boneskull boneskull removed status: waiting for author waiting on response from OP - more information needed pr-needs-work labels Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants