我在 packadge.json 中有
"scripts": {
"test": "cross-env NODE_ENV=test jest"
},
我想测试所有文件匹配模式
front/**/*.test.js
但是如果
"scripts": {
"test": "cross-env NODE_ENV=test jest \"front/**/*.test.js\""
},
我有一个错误
Invalid testPattern front/**/*.test.js supplied. Running all tests instead.
那么,我如何将文件名模式传递给 jest?
谢谢。
最佳答案
根据documentation你应该为你的模式使用正则表达式。所以在你的情况下你可能会写这样的东西:
"scripts": {
"test": "cross-env NODE_ENV=test jest \"front/.*\\.test\\.js\""
}
关于reactjs - Jest 如何在 package.json 脚本中设置文件模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50971278/