You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever I call Login() a second time on a different user, it does not login as expected. Calling login() a second time on the same user works just as expected. Why is this small test case not logging in as expected?
describe('empty spec', () => {
beforeEach(function () {
cy.create({model: 'App\\Models\\User', state: {'representative':[],}}).as('regularUser1')
cy.create({model: 'App\\Models\\User', state: {'representative':[],}}).as('regularUser2')
});
it('Example Test Case', function () {
cy.visit('/')
cy.login({id:this.regularUser1.id})
cy.visit('/')
cy.url().should('contain', '/dashboard') // this works
cy.logout()
cy.visit('/')
cy.login({id:this.regularUser2.id})
cy.visit('/')
cy.url().should('contain', '/dashboard') // this fails, will be redirected to the login page instead
})
})
The text was updated successfully, but these errors were encountered:
Okay, so clearing cookies between the login calls seem to work, but this is pretty cumbersome having to do this every time. Is there any way around this? Working example below:
describe('empty spec', () => {
beforeEach(function () {
cy.create({model: 'App\\Models\\User', state: {'representative':[],}}).as('regularUser1')
cy.create({model: 'App\\Models\\User', state: {'representative':[],}}).as('regularUser2')
});
it('Example Test Case', function () {
cy.visit('/')
cy.log(this.regularUser1.id)
cy.login({id:this.regularUser1.id})
cy.visit('/')
cy.url().should('contain', '/dashboard') // this works
cy.logout()
cy.visit('/')
cy.clearCookies().then(function () {
cy.login({id:this.regularUser2.id})
cy.visit('/')
cy.url().should('contain', '/dashboard') // This works as well now!
})
})
})
Whenever I call Login() a second time on a different user, it does not login as expected. Calling login() a second time on the same user works just as expected. Why is this small test case not logging in as expected?
The text was updated successfully, but these errors were encountered: