Currently, I am utilizing the jest cli for running my tests. Jest offers a useful cli option known as --runTestsByPath
, which allows me to specify the locations of my tests.
Despite having unit tests spread out in various directories within my repository, I aim to execute them all using a single command. One approach is to string together different jest commands using &&
:
{
"name": "node-project",
"version": "0.0.0",
"scripts": {
"test": "jest --runTestsByPath ./__tests__/tests/over/here/*_test.ts && jest --runTestsByPath ./tests/over/__tests__/here/*_test.ts"
},
"devDependencies": {
"jest": "24.8.0",
"ts-jest": "24.0.2",
"ts-node": "8.3.0",
"typescript": "2.9.2"
}
}
However, this method comes with a drawback: it eliminates certain functionalities such as coverage that are obtainable when all tests are run using just one jest command.
I have a query regarding the usage of --runTestsByPath
: Is there a way to pass multiple paths to it? Despite my extensive search efforts, I have not found any documentation or answers on this matter on sites like SO.