A simple Cypress plugin for passing data between test scenarios
API
command
action
cy.store
stores data
cy.getStored
gets stored data
cy.removeStored
removes stored data
cy.flushStored
flushes all stored datas
cy.logStored
logs all stored datas
Install
npm i -D cypress-store
Add to your Cypress commands.js file
import "cypress-store";
Usage
To store data :
cy.store(<key>, <value>);
parameter
mandatory
type
key
✅
string
value
any
To get stored data :
cy.getStored(<key>);
//Cypress wraps the retrieved value so you can access it with :
cy.getStored(<key>).should("eql", <value>);
// Or :
cy.getStored(<key>).then((key) => {
console.log(key);
});