close
  • 简体中文
  • includeTaskLocation

    • 类型: boolean
    • 默认值: false
    • CLI: --includeTaskLocation

    在收集测试信息时,是否包含测试的位置信息。

    启用此配置后,会为测试用例和测试套件添加行号和列号信息,这对于调试和 reporter 中收集测试信息非常有用。

    需要注意的是,启用此配置会导致性能小幅度下降。

    CLI
    rstest.config.ts
    npx rstest --includeTaskLocation

    与 list 命令一起使用

    includeTaskLocation 选项在与 list 命令一起使用时特别有用,当您想要查看测试的确切位置时:

    npx rstest list --printLocation

    这将自动启用 includeTaskLocation 并显示每个测试用例的位置信息。

    示例输出

    启用后,reporter 和 list 命令将包含位置信息:

    {
      "testId": "test-1",
      "name": "should calculate correct sum",
      "testPath": "/path/to/test.spec.ts",
      "location": {
        "line": 15,
        "column": 3
      }
    }