cypress-image-snapshot icon indicating copy to clipboard operation
cypress-image-snapshot copied to clipboard

Property 'matchImageSnapshot' does not exist on type 'cy & EventEmitter'

Open iten74 opened this issue 4 years ago • 4 comments

Configured the plugin as outlined but cypress does not recognize it. The plugin works if I add @ts-ignore in front of the line cy.matchImageSnapshot();, but I'd rather be able to configure the framework correctly so cypress doesn't complain. Any idea?

index.js:

const cucumber = require('cypress-cucumber-preprocessor').default;
const browserify = require('@cypress/browserify-preprocessor');
const resolve = require('resolve');
const { addMatchImageSnapshotPlugin } = require('cypress-image-snapshot/plugin');

module.exports = (on, config) => {
    const options = {
        ...browserify.defaultOptions,
        typescript: resolve.sync('typescript', { baseDir: config.projectRoot })
    };
    on('file:preprocessor', cucumber(options));
    addMatchImageSnapshotPlugin(on, config);
};

commands.js

import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';
addMatchImageSnapshotCommand();

iten74 avatar Aug 24 '21 00:08 iten74

Try to run npm i @types/cypress-image-snapshot -D

ma-bourassa avatar Sep 10 '21 16:09 ma-bourassa

Solved it for me. Thanks @ma-bourassa!

DCzajkowski avatar Sep 14 '21 12:09 DCzajkowski

I also needed /// <reference types="cypress-image-snapshot" />

jake-nz avatar Oct 11 '21 23:10 jake-nz

@ma-bourassa, even I add the @types/cypress-image-snapshot, there is same error. But if i add this: /// , it will resolved. I do not want to add this reference in all of my test file. is there is way to fix without writing reference?

dhakalsamundra avatar May 12 '22 11:05 dhakalsamundra