Reputation: 4685
Is there a jest equivalent, or a way of doing it in bash, to the git regex approach for including files that match one regex (all files in the /tests
folder), but then exclude any that match a second (any test files that include API
in the name)? e.g.
git ls-files -- 'tests' ':!:*API*'
I would like to do it as single line command because I want to be able to run all the tests in the /tests
directory, but in two mutually exclusive sets using a single yarn test
script from my package.json
file.
EDIT: Expanding on Brenda J. Butler's answer:
yarn jest `find tests -type f ! -name \*API\* | grep -v .DS_`
jest
can take either a regex OR a file list,grep -v
to also pull out the .DS_Store
from the file list.Upvotes: 0
Views: 813
Reputation: 1485
bash:
# finding files under tests whose names don't contain API
$ find tests -type f ! -name \*API\*
# finding files under tests whose names contain API
$ find tests -type f -name \*API\*
Upvotes: 1