【问题标题】:Jest --runTestsByPath two or more different pathsJest --runTestsByPath 两个或多个不同的路径
【发布时间】:2019-12-22 22:57:54
【问题描述】:

我正在使用jest cli 运行我的测试。 Jest 有一个名为 --runTestsByPath 的 cli 选项,我用它来指定我的测试在哪里。

我的单元测试分布在我的存储库的不同目录中,但我想在一个命令中运行它们。一种选择是&& 不同的笑话命令:

{
  "name": "node-project",
  "version": "0.0.0",
  "scripts": {
    "test": "jest --runTestsByPath ./__tests__/tests/over/here/*_test.ts && jest --runTestsByPath ./tests/over/__tests__/here/*_test.ts",
  },
  "devDependencies": {
    "jest": "24.8.0",
    "ts-jest": "24.0.2",
    "ts-node": "8.3.0",
    "typescript": "2.9.2"
  }
}

但是,我失去了通过 1 个 jest 命令运行它们所获得的覆盖等功能。

我想知道,因为它没有在任何地方记录,也没有在 SO 上回答,我如何将两个或多个不同的路径传递给 --runTestsByPath

【问题讨论】:

    标签: javascript typescript unit-testing testing jestjs


    【解决方案1】:

    我们可以将多个路径传递给 jests --runTestsByPath cli 选项:

    jest --runTestsByPath ./__tests__/tests/over/here/*_test.ts ./tests/over/__tests__/here/*_test.ts
    

    【讨论】:

      猜你喜欢
      • 2018-06-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-30
      • 2021-08-15
      • 1970-01-01
      • 1970-01-01
      • 2017-04-21
      相关资源
      最近更新 更多