如何覆盖 on_failure 截图的命名?

How to override the naming of on_failure screenshots?

不幸的是,由于使用黄瓜并写出场景,我最终得到了令人难以置信的长文件名,windows 对此表示抱怨。是否可以覆盖文件的命名?

我假设您正在使用 Nightwatch 框架,因为您已经在 post 中标记了它。

看起来截图文件名是在 nightwatch/lib/api/client-commands/end.js 最新 repo const prefix = '${this.api.currentTest.module}/${this.api.currentTest.name}'; 的第 26 行中定义的。

截图路径定义在你的nightwatch.json:

{
  "test_settings" : {
    "default" : {
      "screenshots" : {
        "enabled" : true,
        "on_failure" : true,
        "path" : "./screens"
      }
    }
  }
}

看来您有几个选择:

  1. 修改 end.js 中的代码以使用自定义命名方案,并使用自定义框架
  2. 缩短测试模块名称或测试名称
  3. 缩短 nightwatch.json 中的屏幕截图目标路径 - 不太可能解决任何问题,因为你说的是​​文件名问题。

这应该可以通过使用 filename_format 选项来实现,因为: #2023 was merged