Q:

mocha run tests twice

I have a several tests for node js express application written in coffeescript run under Mocha control. 
Unfortunately mocha runs all my tests twice, becouse in the same directory I jave .coffee and .js files. The .js files are generated by my editor automatically together with .map files. That's quite handy if I need to debug something. 
How can I filter that only .coffee or .js are executed from directory not both of them?

A:

In your package.json, create entries like the following:
  "scripts": {
    "test": "npm run test-coffee",
    "test-js": "mocha -R spec test/*.js",
    "test-coffee": "mocha -R spec test/*.coffee"
  }

Now you can run npm test, npm run test-js, or npm run test-coffee. If you have tests in subdirectories, you will want to use the find command to run just the subtests you're interested in.

