cannot get cy.session to work as a replacement for Cypress.Cookies.defaults({ preserve: #25129
Unanswered
tfaron
asked this question in
Questions and Help
Replies: 1 comment
-
I recommend turning off
This way, the session will not be cleared between it-s. |
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.
-
In my current code I launch my application, login via username and password and once the app loads I run the following command which is called in the BEFORE block:
Cypress.Cookies.defaults({
preserve: ['auth-token', 'access-token', 'userData'],
})
In the BEFOREACH block I run 'cy.reload()' and this is making is so I only have to login once and just reload the browser before each test
I am trying to do the same with cy.session() without success, trying multiple variations and also trying to use set/get cookies
I put the following code in BEFORE
Cypress.Commands.add('login', (username, password) => {
cy.visit('/login')
cy.get('[data-test=name]').type(username)
cy.get('[data-test=password]').type(password)
cy.get('form').contains('Log In').click()
cy.url().should('contain', '/login-successful')
})
In BEFOREEACH i call 'login()' and all I get is the login page displayed
If i call 'cy.refresh()' in beforeEach nothing is happening
I am clearly missing something or this is not working as expected.
Any suggestions on how to get this to work?
Beta Was this translation helpful? Give feedback.
All reactions