
What can be better in mocha.js?
Mocha.js is awesome test runner. I am using it in all my own modules.
It was created several years ago learning mistakes of previous test runners. And now after years of usage it is clear some design mistakes and drawbacks.
Globals
To write test using TDD/BDD interfaces we are using test/suite/describe/it etc. Which mocha implicitly add to global scope.
All exiting linters adds special flag to ignore mocha globals.
From this point also going another disadvantage — we cannot simply run test with node executable, we must use mocha executable. The same about building test for running in browser — you must include mocha script in its html reporter. Actually there is zuul project which allows automatically run mocha tests building it with browserify. I would expect the same (or similar job from mocha html reporter). Maybe someone will tell it is not deal of mocha to run tests in browsers — there is better tools etc (like karma — which is actually browser runner), but it is pretty ok at the end of 2015 to require this from test runner.
Huge code base
A lot of issues in mocha repo at GitHub about its reporters. Which actually should be moved in their own repositories. There is a lot of good sides of this change, and almost none bad.
Common Implicitness
In mocha too many implicit places. There is no easy way to hook to its internals. There is no easy way to change reporter state/output. E.g. i was disappointed with spec reporter and wanted to add some possibilities to it — like i wanted to see file content where error happen directly under stack line, do not see stack for timeouts etc. At the end i finish with my mocha-better-spec-reporter.
I will try to fix this in my last module ‘toster’. Maybe i will write about it later.