vendredi 6 mai 2016

Test command that loops through all subdirectories

I am making a project in node. I am using Mocha to test my React code. I have written my test files next to the components they are testing. e.g.

Card
   |__card-component.js
   |__card-test.js

My package.json has a scripts.test property that reads:

"mocha --compilers js:babel-core/register --require ./src/global/test-helper.js --recursive ./src/*-test.js"

This command works fine to run my tests. However, it only searches one directory deep, because of ./src/*-test.js.

I would like for it to search ALL subdirectories, so for instance:

./src/*-test.js + ./src/**/*-test.js + ./src/**/**/*-test.js + ...

The only solution I have is:

"mocha --compilers js:babel-core/register --require ./src/global/test-helper.js --recursive ./src/*-test.js --recursive ./src/**/*-test.js --recursive ./src/**/**/*-test.js"

but this is fairly verbose, and it must be modified every time I need to go another directory deeper.

Is there a way to write ./src/*-test.js such that it goes through ALL subdirectories?

Aucun commentaire:

Enregistrer un commentaire