Cypress changes headers to lazyUpdate

Viewed 32

I'm running Cypress (10.4.0) with an Angular (10.1.6) project and I'm running into an issue with the headers. At some point during a test the headers are moved into something called lazyUpdate:

enter image description here

Which causes an error with http.js:

Which crashes the application.

My test is fairly simple:

describe('Login with an custom email-address', () => {
    it('Visits the login page', () => {
        cy.visit('/');
    });

    it('fills in the login form', () => {
        cy.el('inputEmailAddress').type(Cypress.env('EMAIL'));
        cy.el('inputPassword').type(Cypress.env('PASSWORD'));
        cy.el('buttonLogin').click();
        cy.url().should('not.contain', 'login');
    });
});

When I use the application myself the headers never change to the lazyUpdate headers.

enter image description here

1 Answers

The issue was that we use some values from local storage to set the headers, but Cypress clears out local storage between tests causing headers to get undefined. Using the cypress-localstorage-commands plugin to store and retrieve headers between tests resolved the issue.

Related