【发布时间】:2022-11-19 01:22:10
【问题描述】:
当我尝试使用此代码调整快照大小时,它不会调整控件的剪辑大小,而是捕获对快照的完全控制
cy.xpath('//div[@id="gis-1"]').toMatchImageSnapshot({
name:"test1",
clip:{width: 400, height: 300,x: 20, y: 20}
});
在我的 cypress.json 中配置
{
"env": {
"dssecurity_url": "<dssecurity>",
"connection_url": "<connection>",
"cypress-plugin-snapshots": {
"autoCleanUp": false,
"autopassNewSnapshots": true,
"diffLines": 3,
"excludeFields": [],
"ignoreExtraArrayItems": false,
"ignoreExtraFields": false,
"normalizeJson": true,
"prettier": true,
"imageConfig": {
"createDiffImage": true,
"resizeDevicePixelRatio": true,
"threshold": 0.01,
"thresholdType": "percent"
},
"screenshotConfig": {
"blackout": [],
"capture": "fullPage",
"clip": null,
"disableTimersAndAnimations": true,
"log": false,
"scale": false,
"timeout": 30000
},
"serverEnabled": true,
"serverHost": "localhost",
"serverPort": 2121,
"updateSnapshots": false,
"backgroundBlend": "difference"
}
},
"viewportHeight": 760,
"viewportWidth": 1200,
"ignoreTestFiles": [
"**/__snapshots__/*",
"**/__image_snapshots__/*"
]
}
有谁知道如何修理它?非常感谢
【问题讨论】:
-
请围绕您收到的错误添加更多详细信息——“它不起作用”不够具体。
标签: typescript xpath cypress snapshot