Skip to content

DevertNet/Shopware6PluginTester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shopware6PluginTester

Cypress Browser Testing for Shopware 6 Plugins. This tool will test your plugin against every SW6 version (>6.5) with your custom cypress tests. With the magic of ddev on every run of this tool the shopware 6 instances will be reseted to a fresh sw6 installtion.

Requirements

Usage

  • Clone this repo anywehere
  • Fire npm install
  • Open cypress to write tests: ./run.sh 6.5.4.0 /path/to/your/YourPluginName/ e.g. ./run.sh 6.5.4.0 /home/leon/htdocs/git/DevertAutoMetaDetails/

Plugin path

Your plugin directory (e.g. /path/to/your/plugin/) should contain the hole plugin. So the composer.json should be here: /path/to/your/plugin/composer.json The directory will be copied to every shopware instance e.g. shopware/6.5.4.0/custom/plugins/YourPluginName The folder must be named like the plugin e.g. YourPluginName

Cypress Tests

Cypress search the tests in your plugin directory (e.g. /path/to/your/plugin/). So in the background cypress will be launched with your plugin directory as project path.

  • /path/to/your/plugin/cypress
  • /path/to/your/plugin/cypress.json

Keep & Clear Cookies

By default Cypress does not keep cookies across tests. cypress/support/commands.js

Keep all cookies

Cypress.Cookies.defaults({
  whitelist: function (cookie) {
    return true;
  },
});

Clearing all cookies with one command does not work. Use this in your tests:

cy.clearCookie("tax_switch"); //Custom cookie
cy.clearCookie("cookie-preference"); //Cookie Consent Bar
cy.clearCookie("session-"); //User Session

Keep LocalStorage

By default Cypress does not keep the local storage across tests. cypress/support/commands.js

(Source: https://stackoverflow.com/a/55234197)

Cypress.Commands.add("saveLocalStorage", () => {
  cy.log("saveLocalStorage");
  Object.keys(localStorage).forEach((key) => {
    LOCAL_STORAGE_MEMORY[key] = localStorage[key];
  });
});

Cypress.Commands.add("restoreLocalStorage", () => {
  cy.log("restoreLocalStorage");
  Object.keys(LOCAL_STORAGE_MEMORY).forEach((key) => {
    localStorage.setItem(key, LOCAL_STORAGE_MEMORY[key]);
  });
});

beforeEach(() => {
  cy.restoreLocalStorage();
});

afterEach(() => {
  cy.saveLocalStorage();
});

Clear shopware Cache during a test

tbd

Change shopware configuration

tbd

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages