node.js - 在 package.json 中使用 Jest --testNamePattern=<regex> 或 -t 选项

标签 node.js testing jestjs

如何使用 Jest --testNamePattern=<regex>-t package.json 中的选项

jest -t /.*flow.spec.js$/ 

jest -t='.*flow.spec.js$'

不起作用。

最佳答案

这种情况下的混淆是 --testNamePattern 用于匹配测试套件中的测试名称而不是文件。提供的示例可能不会像预期的那样匹配:

describe('Test suite', () => {
  test('something.flow.spec.js', () => {
    //... tests here
  });
});

要改为按文件名匹配,应使用 --testPathPattern 参数。在这种情况下尝试:

--testPathPattern=.*flow.spec.js$

关于node.js - 在 package.json 中使用 Jest --testNamePattern=<regex> 或 -t 选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45913349/

相关文章:

webpack - Jest 测试失败,错误代码为 "window is not defined"

javascript - 使用 Jest 模拟请求 header 模块

node.js - 在mongodb聚合中仅提取$project中键值对中的值

java - 如何在运行时定义 JUnit 测试超时(即没有注释)?

javascript - 如何对 Ext JS 应用程序进行端到端测试

json - 在哪里可以找到用于测试的预填充 json 文件?

javascript - 如何使用 create-react-app 设置 Jest Watch 插件

javascript - 摇树萨斯

javascript - 在node.js中显示javascript对象内容

javascript - 如何在调用post方法后更改使用multer上传的文件的名称