首页 > 解决方案 > 在 cypress 文件夹外指定 customSnapshotsDir 时出错

问题描述

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

我们真的可以将屏幕截图文件保存到与 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

解决方案


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

只需添加screenshotsFolder属性。

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

推荐阅读