(For Node.js only.)
To protect mocha tests (and before and after commands) from uncaught exceptions, in each test file:
{protect} = require './test_helper'
protect()
describe 'my thing', ->
it 'does something', (done) ->
...
Frustratingly you have to call it in each test file as mocha effectively redefines it
, before
and after
on every file it runs.
NOTE: This used to use domains, but it turns out Mocha just messes up the uncaughtException handler; so we get rid of Mocha's and use our own. Simples.