仅为失败的测试用例录制视频

Ami*_*mar 8 cypress

如何使用cypress只为CI管道中失败的测试用例录制视频,我应该做什么配置来实现这一点?我的cypress.json看起来如下:

{
    "defaultCommandTimeout": 30000,
    "pageLoadTimeout": 120000,
    "requestTimeout": 30000,
    "responseTimeout": 30000,
    "execTimeout": 30000,
    "taskTimeout": 30000,
    "screenshotsFolder": "cypress/screenshots",
    "trashAssetsBeforeRuns":true,
    "testFiles": "**/*Smoke.spec.ts",
    "video": false,
    "videosFolder": "build/cypress/videos",
    "viewportWidth": 1300,
    "viewportHeight": 1000,
    "animationDistanceThreshold": 50,
    "reporter": "junit",
    "reporterOptions": {
      "mochaFile": "build/cypress/test-output-[hash].xml",
      "toConsole": true,
      "attachments": true
    }
}
Run Code Online (Sandbox Code Playgroud)

Cyc*_*ycy 6

据我所知,Cypress 无法选择仅保留失败测试的视频而不是通过测试的视频 - 但是...最近发布的 Cypress 6.2.0 包含在规范执行或相关有趣点触发的新事件整个试运行。Cypress 开发人员建议在 Github 上使用它们来达到测试成功时删除视频文件的确切目的。通过这种技术,一旦 Cypress 完成运行测试,包含视频的目录(videosFolder在您的 中cypress.json)将仅包含失败测试的视频文件。然后由您决定让 CI 工具存档此目录。祝你好运!