Uncaught errors being obfuscated when loading
Closed this issue · 2 comments
tomdale commented
I see you just merged 0ead1ce, which catches uncaught exceptions and adds them to the test output. This is awesome—except for the case where the exception happens while evaluating the code you are testing.
This is pretty simple to reproduce. Simply introduce a syntax error to the code you're testing. Instead of getting a helpful error message, like this:
kamino.js » qunit -c ./lib/kamino.js -t ./tests/simple.js ~/Code/kamino.js
Testing /Users/tomdale/Code/kamino.js/lib/kamino.js ...
/Users/tomdale/Code/kamino.js/lib/kamino.js:24
a;sfjk;sdfa89u;+asdf;j
^
ReferenceError: a is not defined
at Object.<anonymous> (/Users/tomdale/Code/kamino.js/lib/kamino.js:24:1)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at _require (/usr/local/lib/node_modules/qunit/lib/child.js:35:19)
at Object.<anonymous> (/usr/local/lib/node_modules/qunit/lib/child.js:126:1)
at Module._compile (module.js:449:26)
You get an error message like this:
kamino.js » qunit -c ./lib/kamino.js -t ./tests/simple.js ~/Code/kamino.js
Testing /Users/tomdale/Code/kamino.js/lib/kamino.js ...
/usr/local/lib/node_modules/qunit/support/qunit/qunit/qunit.js:414
throw new Error( "ok() assertion outside test context, was " + sourceFromSt
^
Error: ok() assertion outside test context, was at process.<anonymous> (/usr/local/lib/node_modules/qunit/lib/child.js:17:11)
at process.EventEmitter.emit (events.js:126:20)
at F.QUnit.assert.ok (/usr/local/lib/node_modules/qunit/support/qunit/qunit/qunit.js:414:10)
at process.<anonymous> (/usr/local/lib/node_modules/qunit/lib/child.js:17:11)
at process.EventEmitter.emit (events.js:126:20)
tomdale commented
I think just checking to see whether there is a current test in progress, and re-raising if not, should fix the issue.
kof commented
This is truth.