[英]Using cypress-plugin-snapshots returns .toMatchSnapshot is not a function
I'm trying to use cypress-plugin-snapshots to take some snapshots of JavaScript objects. 我正在尝试使用cypress-plugin-snapshots拍摄一些JavaScript对象的快照。
I have followed the Configure Cypress.io instructions on https://www.npmjs.com/package/cypress-plugin-snapshots but when I run my test (below) I receive the following error 我已按照https://www.npmjs.com/package/cypress-plugin-snapshots上的Configure Cypress.io说明进行操作,但是在运行测试时(如下所示),我收到以下错误消息
1) Check snapshots Should match snapshot: TypeError: expectedData.toMatchSnapshot is not a function at Context.<anonymous> (https://www.bbc.com/__cypress/tests?p=cypress/integration/data_driven.js-917:24:18)
My test file is: 我的测试文件是:
describe('Check snapshots', function () {
it('Should match snapshot', () => {
const expectedData = {
fonts:
[ { familyName: 'Helvetica', isCustomFont: false, glyphCount: 10 },
{ familyName: 'Gurmukhi MN', isCustomFont: false, glyphCount: 33 } ]
}
expectedData.toMatchSnapshot();
});
});
I'm relatively new to both JS (and Cypress) so I am not sure exactly what it is I am doing wrong. 我对JS(和赛普拉斯)都比较陌生,所以我不确定到底是我做错了什么。 If anyone has experience sorting this issue out I'd be really grateful for some input.
如果有人有解决此问题的经验,我将不胜感激。
你只需要来包装你的对象expect
:
expect(expectedData).toMatchSnapshot()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.