I'm trying to use cypress-plugin-snapshots to take some snapshots of JavaScript objects.
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
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. If anyone has experience sorting this issue out I'd be really grateful for some input.
你只需要来包装你的对象expect
:
expect(expectedData).toMatchSnapshot()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.