Unable to restore user from cookie with cypress-data-session #22591
Unanswered
NirShihor
asked this question in
Questions and Help
Replies: 2 comments
-
hello! 👋 have you tried this plugin to keep the whole localStorage between Cypress tests? |
Beta Was this translation helpful? Give feedback.
0 replies
-
I need to retain session across spec files, not just tests.
Thanks,
Nir
…
On Jul 25, 2022 at 3:53 PM, <Sara Tavares ***@***.***)> wrote:
hello! 👋
have you tried this (https://www.npmjs.com/package/cypress-localstorage-commands) plugin to keep the whole localStorage between Cypress tests?
—
Reply to this email directly, view it on GitHub (#22591 (comment)), or unsubscribe (https://github.com/notifications/unsubscribe-auth/AOVIIZWUUGCPY77CD674FFDVV2S6VANCNFSM52GA7QSA).
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Would anyone familiar with cypress-data-session library know why this is not working?
The set-up for the user works insofar as it goes through the signin process and into the account page, with tests passing.
However, on consequent runs, once the user has been created and stored, the recreate section fails and the page opens again at the signin.
`
beforeEach(function () {
const userEmail = this.Email.toString()
const userPassword = '12qwER£$'
cy.dataSession({
name: 'User',
setup() {
cy.visit('/account/signin')
cy.get('#email').type(userEmail)
cy.get('#password').type(userPassword)
cy.get('[data-testid=signin]').should('be.visible').trigger('mouseover').click({ force: true })
cy.location('pathname').should('eq', '/account/')
cy.getCookie('builderSessionId')
},
validate: true,
recreate(cookie) {
cy.setCookie('builderSessionId', cookie.value)
cy.visit('/account/')
},
shareAcrossSpecs: true
})
})
`
Beta Was this translation helpful? Give feedback.
All reactions