开玩笑如何在 package.json 脚本中设置文件模式 [英] jest how set file pattern in package.json script

查看:22
本文介绍了开玩笑如何在 package.json 脚本中设置文件模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 packadge.json 中有

I have in packadge.json

"scripts": {
  "test": "cross-env NODE_ENV=test jest"
},

我想测试所有文件匹配模式

I want to test all files match pattern

 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?

So, how could I pass file names pattern to jest?

谢谢.

推荐答案

根据 documentation 您应该为您的模式使用正则表达式.所以在你的情况下,你可能会写这样的东西:

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""
}

这篇关于开玩笑如何在 package.json 脚本中设置文件模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆