【问题标题】:Using Jest --testNamePattern=<regex> or -t option in package.json在 package.json 中使用 Jest --testNamePattern=<regex> 或 -t 选项
【发布时间】:2017-08-28 06:59:29
【问题描述】:

如何在 package.json 中使用 Jest --testNamePattern=&lt;regex&gt;-t 选项

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

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

不起作用。

【问题讨论】:

    标签: node.js testing jestjs


    【解决方案1】:

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

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

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

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

    【讨论】:

      猜你喜欢
      • 2021-08-14
      • 2019-06-21
      • 2016-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-03
      • 2019-08-24
      相关资源
      最近更新 更多