acceptable-solstice-90676
10/26/2022, 3:16 PMe2e.js file (see file attached), that works pretty good for me, but I face a problem, if a test fails or for some reason is not finished, and the next one is going to run, Cypress is logging in with the account of the test that failed, even if I have one of these options set in before/beforeEach/after/afterEach:
- cy.clearCookies
- cy.clearCookie('sessionID')
- Cypress.session.clearAllSavedSessions()`
I logging as follow:
Cypress.Commands.add('loginByAPI', (email, password='mypassword') => {
cy.clearCookies('sessionID') //added this to try here
cy.request({
method: 'POST',
url: Cypress.env('accountAPIUrl') + '/security/login2',
body:
{
"email": email,
"password": password,
}
}).then((response) => {
expect(response.status).to.eq(200)
cy.log({ name: 'loginResponse', message: response.body.sessionID })
cy.log({ name: 'loginResponse', message: response.body.email })
cy.setCookie('sessionID', response.body.sessionID)
cy.visit(/);
})
})