I don't want it to login in each time I write a test. When I write "it (cypress)" more than once, it goes back and does a re-login, which I don't want it to happen.
It logins, and after the first test pass, it goes on second test but it does a second login to do the "second it" test. How can I stop it?
describe('Integration Tests', function () {
beforeEach(() => {
cy.login()
})
it('first it', function () {
cy.get('.css-vj8t7z')
cy.get('.css-1ep9fjw')
})
it('second it', function () {
cy.get('.css-1ep9fjw')
})
First find out the cookie it used to login.
Then try some code like below
describe('Integration Tests', function () {
before('login once', function () {
cy.login()
}
beforeEach('keep using the session', function () {
Cypress.Cookies.preserveOnce("YourCookie")
})
it('first it', function () {
cy.get('.css-vj8t7z')
cy.get('.css-1ep9fjw')
})
it('second it', function () {
cy.get('.css-1ep9fjw')
})
read more here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With