jaredpalmer / cypress-image-snapshot

Catch visual regressions in Cypress
MIT License
891 stars 158 forks source link

Problem running on docker image cypress/included:3.8.0 #110

Closed asharpefr closed 4 years ago

asharpefr commented 4 years ago

Hi, I'm trying to use cy.matchImageSnapshot(key) on GitLab CI with docker image, but I'm having the following error:

CypressError: cy.task('Matching image snapshot') failed with the following error:

The 'task' event has not been registered in the plugins file. You must register it before using cy.task()
Fix this in your plugins file here:
/builds/project/cypress/plugins/index.js
https://on.cypress.io/api/task

It works perfectly when I'm running the specs locally but strangely it fail when they are runned on the docker image cypress/included:3.8.0 by the gitlab CI.

I have in plugins\index.js :

const {
  addMatchImageSnapshotPlugin,
} = require('cypress-image-snapshot/plugin');

module.exports = (on, config) => {
  addMatchImageSnapshotPlugin(on, config);
};

in support\commands.js :

import 'cypress-wait-until';
import {addMatchImageSnapshotCommand} from 'cypress-image-snapshot/command';

addMatchImageSnapshotCommand();

Package.json

"cypress": "^3.8.0",
"cypress-image-snapshot": "^3.1.1",
"cypress-wait-until": "^1.4.2",

I can't find what I missed. Thanks

asharpefr commented 4 years ago

I solved it, the plugins\index.js file was dismissed and not taken into account.