Update (2018): Much has changed in Mocha since this post was written in 2015.
Mocha is a great way to test JavaScript, but its stack traces are riddled with useless frames from Mocha internals and 3rd-party modules. Let's try and clean it up.
mocha-clean
is a plugin for Mocha. It strips away mocha internals,
node_modules, absolute paths (based on cwd), and other unneccessary cruft
from stack traces.
Simply invoke Mocha with -r mocha-clean
. The easiest way to do this is to add it to your test/mocha.opts file.
It's available via npm, and works with Mocha 1.x in Node.js and in the browser. The source is available in GitHub: rstacruz/mocha-clean.
A pull request is currently open in Mocha to integrate this functionality into Mocha itself. Check out #1564 and offer your support and comments.