elegant-insurance-66438
05/11/2023, 8:09 PMcy.session to login a user and I need to validate the token has been set in local storage, however when using the validate() method the result from cy.getAllLocalStorage() does not contain the token item - the login is succesful though as the user is redirected as expected and that test passes. Here is my code.
Cypress.Commands.add("loginViaUi" as any, (user: any) => {
cy.session(
user,
() => {
cy.visit("/public/login");
cy.get("#username").type(user.username, { log: false });
cy.get("#password").type(user.password, { log: false });
cy.get(".ant-btn").click();
},
{
cacheAcrossSpecs: true,
validate: () => {
cy.getAllLocalStorage().then((result) => {
console.log("result", result);
});
},
}
);
});echoing-kangaroo-83836
05/12/2023, 1:57 AMechoing-kangaroo-83836
05/12/2023, 1:57 AMelegant-insurance-66438
05/12/2023, 9:15 AM