https://cypress.io logo
Cy.session restored not working in GitLab CI but w...
# i-need-help
w
I'm using cy.session for login and once the session is restored, I'm not logged in. I have tried both chrome and the electron browser in gitlab ci and magically it only worked once. But I don't see any issue with this in my local. here is my login logic
Copy code
Cypress.Commands.add('loginWithSession', () => {
  cy.session('loginWithSession', () =>{
    cy.loginWithWeb();
  },{
    cacheAcrossSpecs: true,
  });
  cy.visit('/');
});
@gray-kilobyte-89541 Could you please help me with this issue! I have read most of the documentation related to cy.session but I'm not sure what am i missing on my CI I'm using Cypress docker image to run my test cases
cypress/browsers:node-16.18.1-chrome-109.0.5414.74-1-ff-109.0-edge-109.0.1518.52-1
as I mentioned my testcases are working as expected in my local. cy.session is restoring the session and after the restore
cy.visit('/')
user is not logged in! 😦 Thank you so much for you time in advance. really appreciate it
g
I am sorry, I don't use
cy.session
, I use my own
cy.dataSession
But I do plan to cover
cy.session
in my course https://cypress.tips/courses/swag-store
w
@wonderful-carpenter-84941 Cypress.Commands.add('loginWithSession', () => { cy.session('loginWithSession', () =>{cy.visit('/') cy.loginWithWeb(); },{ cacheAcrossSpecs: true, }); });
loginWithSession() is used before each hook.. and cy.visit('/) use in each it block.
w
@gray-kilobyte-89541 thank you so much for reply 🙂
I will checkout cy.dataSession!