matchawine / cypressDataSnapshot

Integrates the awesome Jest snapshot testing to Cypress
MIT License
3 stars 0 forks source link

Support Cypress 10 #7

Open Michael-1 opened 2 years ago

Michael-1 commented 2 years ago

For compatibility for Cypress 10, a few changes are required, notably

abrioy commented 2 years ago

I have a quick fix to get this plugin running with Cypress 10 until it's updated.

If you have this error :

Error running e2e.setupNodeEvents() > The ignoreTestFiles configuration option is now invalid when set on the config object in Cypress version 10.0.0. > It is now renamed to excludeSpecPattern and configured separately as a testing type property: e2e.excludeSpecPattern

You can remplace the config argument of cypressDataSnapshot in cypress.config.ts by an empty object.

const cypressDataSnapshot = require("cypress-data-snapshot/plugin");

function setupNodeEvents(on, config) => {
  cypressDataSnapshot(on, {});

  return config;
}

And add the excludeSpecPattern yourself in the Cypress config.

abrioy commented 2 years ago

I don't know if it's because I use @badeball/cypress-cucumber-preprocessor or if it's an issue with Cypress 10, but I get an error when I try and create a snapshot:

Cannot read properties of null (reading 'match')

In order to fix this one I have to override the getTestFilePath command:

Cypress.Commands.add('getTestFilePath', () => {
  return cy.wrap(Cypress.spec.absolute);
});