Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How specify test-files with .mocharc config file

I currently run mocha tests with npm scripts like

mocha test/mocha.js test/crc/mocha.js test/multibyte/test.js

I added an additional three test files and I started to think maybe to use a configuration file like .mocharc.js, and call simply mocha, but whatever I try, mocha always runs all .js files in "test" folder.

  • I started with this tutorial where they use file property, but it won't work.
  • Some SO answers point me to mocha example on github where they use watch-files property but it still won't work.
  • I tried to use an absolute path, then a relative path
  • According to mocha official documentation I should use file property, but it won't work.

All this is so confusing and I can't find any config file documentation more than what file names I should use.

Does anyone knows how I can run just these three test-files with a config file ?

I know I can use npm script like before, but maybe there is way ?

like image 394
I Cac Rubin Avatar asked Nov 02 '25 08:11

I Cac Rubin


1 Answers

You can use spec:

.mocharc.json:

{
    "spec": "./test/**/*.js"    
}

Some other examples are in here: How to specify test directory for mocha?

like image 103
pavelsaman Avatar answered Nov 03 '25 21:11

pavelsaman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!