https://cypress.io logo
Hi there, I am new to e2e-testing and I am current...
# e2e-testing
c
Hi there, I am new to e2e-testing and I am currently figuring out how to stay logged in (via Azure AD) while doing several tests. The login logic itself is working fine (I used parts of this repo: https://github.com/juunas11/AzureAdUiTestAutomation). My
cy.loginWithApiCall()
-function is creating several items in the local storage, which than is being used by the website to authenticate the user. The problem which I am facing is with sessions: Currently I have to login for every test, which might lead to a lock down of the account (because of to many calls in a certain period). I would prefer to stay logged in, if that is possible, but have separate tests (
it('test1'), ...
). Is that possible, or is it prevented by design to have isolated tests?
Copy code
ts
/// <reference types="cypress" />

describe('Dashboard', () => {

  it('login via RPOC works correctly', () => {
    cy.session('mySession', () => {
      cy.loginWithApiCall(); //👈call for each test
      cy.visit('/').url().should('include', '/portal');
    });
  });

  it('"Welcome" is visible', () => {
    cy.session('mySession', () => {
      cy.loginWithApiCall(); //👈call for each test
      cy.visit('/portal').contains('Welcome');
    });
  });
});
The strange part is, that the
cy.beforeEach()
function does not work as well (Is it because it is outside the session?). I would think, that I could reuse a session with the same ID, but I guess this is isolated for each
it()
function?