System dispatches "Update" event twice when I use mocha on node.js



I have a workspace uses typescript-rollup-mocha. I am imaging:

  • Save one of /scripts//*.ts or /test//*.ts files
  • Transpile and bundle all /scripts/**/*.ts files by watching file updates
  • Test all /test/**/*.ts files automatically by watching file updates

But once I save a ts file, mocha runs all /test/**/*.ts files twice.
I wrote console.log() in bin/_mocha like this:, function(e) {
    console.log(e); // <--HERE!
    runAgain = true;
    if (runner) {
    else {

Then, console screen displayed updated file name twice.

Therefore, I think “Cloud9’s file system dispatches ‘Update’ event twice in some case”, but I don’t know how do I do.
Do you all know cause of the issue and how to solve?



This is not cloud9 issue, since the same happens when running fs.writeFile directly, usually watchers use a timeout to not run tests when file save is not finished.


I see… The issue might happen because mocha doesn’t use a timeout to “watch” files.
I will give up mocha --watch and seek some sweet testrunners.

Thank you for your help!