Replies: 2 comments
-
As I understand it Cypress is designed to start from a clean slate. So if you want to keep your login active you will have to tell cypress to keep the cookies. Something like this worked for me: // commands.js
Cypress.Commands.add('preserveAllCookiesOnce', () => {
cy.getCookies().then(cookies => {
const namesOfCookies = cookies.map(c => c.name)
Cypress.Cookies.preserveOnce(...namesOfCookies)
})
})
// your-suite.test.js
beforeEach(function () {
cy.preserveAllCookiesOnce()
}); |
Beta Was this translation helpful? Give feedback.
0 replies
-
In my opinion this design sucks but thanks for solution, I will try.
niedz., 16 maj 2021, 14:35 użytkownik Alex Verbruggen <
***@***.***> napisał:
… As I understand it Cypress is designed to start from a clean slate. So if
you want to keep your login active you will have to tell cypress to keep
the cookies. Something like this worked for me:
// commands.js
Cypress.Commands.add('preserveAllCookiesOnce', () => {
cy.getCookies().then(cookies => {
const namesOfCookies = cookies.map(c => c.name)
Cypress.Cookies.preserveOnce(...namesOfCookies)
})
})
// your-suite.test.js
beforeEach(function () {
cy.preserveAllCookiesOnce()
});
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#15743 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMUVMH5Q3LVHT3ZTSOLB2JLTN632RANCNFSM42HEJNNA>
.
|
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.
-
My code I use is below (of course all selector data etc. removed).
Many times the last it() ain't working as in Cypress I see that it displays login page.
Rarely works fine, is there any problem that Cypress looses browser login session?
Plugins > index. js
Support > commands.js
Support > index.js
Beta Was this translation helpful? Give feedback.
All reactions