I'm currently working in an app that keeps info in Session Storage. After the login process, I see the Session Storage being cleared and the DOM being refreshed back to the login screen. I'd like to persist the Session Storage between tests per spec so I don't have to continuously logout and log back in to check multiple things in the same container.
My current setup looks like this:
describe('Quickpanel', () => {
before(() => {
cy.visit(base_url, {onBeforeLoad: (window) => {
window.sessionStorage.setItem('someInfo',
`{"SubsId":${info[0]},"RId":${nfo[1]}}`)
window.sessionStorage.setItem('loc', `${info[2]}`)
}})
LoginPage
.login(login_username, login_password)
Navbar
.clickOnBookingsSubLink('Beta Calendar')
.verifyCalendarLoads()
.clickBookReservationButton()
.verifyQuickPanelIsOpen()
})
First test runs fine and the right session storage values are set and others created using the provided info. When I move to the second "It()" is when the session storage goes away. I've also tried setting the Session Storage items in "beforeEach()" but the same issue occurs.
Any help is appreciated, thank you :)