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

Exceptions in hooks are silent #150

Closed
weepy opened this issue Dec 16, 2011 · 7 comments
Closed

Exceptions in hooks are silent #150

weepy opened this issue Dec 16, 2011 · 7 comments

Comments

@weepy
Copy link

weepy commented Dec 16, 2011

If an exception occurs during a hook (e.g. beforeEach) - it's lost silently - which is difficult to track down where the problem is.

@tj
Copy link
Contributor

tj commented Dec 16, 2011

seems ok to me:

describe('something', function(){
  beforeEach(function(){
    throw new Error('test')
  })

  it('should something', function(){

  })
})

  .

  ✖ 1 of 1 tests failed:

  0) something "before each" hook:
     Error: test
      at Hook.fn (/Users/tj/Projects/mocha/test.js:4:11)
      at Hook.run (/Users/tj/Projects/mocha/lib/runnable.js:150:29)
      at next (/Users/tj/Projects/mocha/lib/runner.js:165:10)
      at Array.0 (/Users/tj/Projects/mocha/lib/runner.js:174:5)
      at EventEmitter._tickCallback (node.js:192:40)

@weepy
Copy link
Author

weepy commented Dec 16, 2011

sorry I should have stated that this was using the browser version.

On Fri, Dec 16, 2011 at 5:01 PM, TJ Holowaychuk
reply@reply.github.com
wrote:

seems ok to me:

describe('something', function(){
 beforeEach(function(){
   throw new Error('test')
 })

 it('should something', function(){

 })
})

 .

 ✖ 1 of 1 tests failed:

 0) something "before each" hook:
    Error: test
     at Hook.fn (/Users/tj/Projects/mocha/test.js:4:11)
     at Hook.run (/Users/tj/Projects/mocha/lib/runnable.js:150:29)
     at next (/Users/tj/Projects/mocha/lib/runner.js:165:10)
     at Array.0 (/Users/tj/Projects/mocha/lib/runner.js:174:5)
     at EventEmitter._tickCallback (node.js:192:40)

Reply to this email directly or view it on GitHub:
#150 (comment)

@tj
Copy link
Contributor

tj commented Dec 16, 2011

ah, gotcha yeah i can reproduce that

@tj tj closed this as completed in 993c6c9 Dec 16, 2011
@tj
Copy link
Contributor

tj commented Dec 16, 2011

thanks for the report!

@weepy
Copy link
Author

weepy commented Dec 18, 2011

-- this doesn't appear to be in the latest mocha.js ?

additionally - it seems to junk the original expection. What was a "object is not a function" throws up "Uncaught TypeError: Cannot read property 'stack' of undefined" in mocha

@tj
Copy link
Contributor

tj commented Dec 18, 2011

hmm i'll reopen and take a look

@tj tj reopened this Dec 18, 2011
@tj
Copy link
Contributor

tj commented Dec 18, 2011

closing, i'll add an issue for this specifically

@tj tj closed this as completed Dec 18, 2011
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

No branches or pull requests

2 participants