Cypress test with session, fails with "401: Unauthorized"

Viewed 469

Cypress test with session, fails with "401: Unauthorized" on line
cy.visit('/admin/people/create');

Why am I getting this error?

file cypress.json

"experimentalSessionSupport": true,

file with test code:

describe('Session testing', () => {
  const login = (name,password) =>{
    cy.session([name,password],()=>{
      cy.visit('/', {
        auth: {
          username: 'username',
          password: 'password',
        },
      });
  
      // Filling field email to 'Log in' form
      cy.get('#edit-name--2').type(name);
      // Filling field pass to 'Log in' form
      cy.get('#edit-pass--2').type(password);
      cy.get('#edit-submit--2').click();

    })
  }

  beforeEach(()=>{
    login('username','password');
  })
  
  // Creating user with 'Organisation responsible' role
  it('Create organisation responsible user', () => {

    cy.visit('/admin/people/create');

  });

});
0 Answers
Related