A simple Cypress plugin for passing data between test scenarios
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 |
npm i -D cypress-store
Add to your Cypress commands.js file
import "cypress-store";
- 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);
});
parameter | mandatory | type |
---|---|---|
key |
✅ | string |
- To remove a stored data:
cy.removeStored(<key>);
parameter | mandatory | type |
---|---|---|
key |
✅ | string |
- To flush all datas:
cy.flushStored();
- To log all datas:
cy.logStored();
Cheers !