Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 794
Luman75 Avatar asked Mar 18 '26 02:03

Luman75


1 Answers

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.

like image 62
Dan Kohn Avatar answered Mar 20 '26 17:03

Dan Kohn