I have in packadge.json
"scripts": {
"test": "cross-env NODE_ENV=test jest"
},
I want to test all files match pattern
front/**/*.test.js
but if
"scripts": {
"test": "cross-env NODE_ENV=test jest \"front/**/*.test.js\""
},
I've got an error
Invalid testPattern front/**/*.test.js supplied. Running all tests instead.
So, how could I pass file names pattern to jest?
Thanks.
According to the documentation you are supposed to use a regex for your pattern. So in your case you probably would write something like this:
"scripts": {
"test": "cross-env NODE_ENV=test jest \"front/.*\\.test\\.js\""
}
Use the testRegex
parameter in your jest config to set a filename pattern:
testRegex: 'front/.*\.test\.js$'
Have a look at the documentation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With