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
})
})
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?