【问题标题】:error when specify customSnapshotsDir outside cypress folder在 cypress 文件夹外指定 customSnapshotsDir 时出错
【发布时间】:2019-07-21 22:25:38
【问题描述】:

当我运行测试时,我不想在代理机器上保存任何屏幕截图 我想将这些图像保存到自定义目录 当我尝试这样做时,我收到此错误 RangeError: Maximum call stack size exceeded。如果我在 cypress 目录中提供一个文件夹路径,比如这个 cypress\my folder

我们真的可以将屏幕截图文件保存到与 cypress 目录不同的文件夹路径吗?

addMatchImageSnapshotCommand(
  {
  failureThreshold: 0.00, // threshold for entire image
  failureThresholdType: 'percent', // percent of image or number of pixels
  customDiffConfig: { threshold: 0.0 }, // threshold for each pixel
  capture: 'viewport', // capture viewport in screenshot
  customSnapshotsDir:'C:\foldername',
  customDiffDir:'C:\foldername'
  }
);

【问题讨论】:

    标签: cypress


    【解决方案1】:

    您可以在cypress.json 文件中更改屏幕截图的默认路径。

    只需添加screenshotsFolder 属性。

    {
        "screenshotsFolder": "./my/custom/path"
    }
    

    【讨论】:

    • 谢谢。此路径是否需要始终相对于 cypress 根目录?
    • 不,您可以设置 PC 上任何文件夹的绝对路径。
    • 我试过这个 - 但是当 cypress 尝试截取屏幕截图时出现错误 RangeError: Maximum call stack size exceeded 。我在 cypress.json 和 command.js 中给出了 "screenshotsFolder": "C:\\Elji" addMatchImageSnapshotCommand( { failureThreshold: 0.00, // 整个图像的阈值 failureThresholdType: 'percent', // 图像或数字的百分比像素数 customDiffConfig: { threshold: 0.0 }, // 每个像素捕获的阈值: 'viewport', // 在屏幕截图中捕获视口 customSnapshotsDir:'C:\\Elji', customDiffDir:'C:\\Elji' } );
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-27
    相关资源
    最近更新 更多