Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
Cypress not saving into localstorage

I'm testing a working web SPA with Cypress, using cypress-localstorage-commands.

before(() => {
    cy.clearLocalStorageSnapshot();
  });

  afterEach(() => {
    cy.saveLocalStorage();
  });

On the first section of code, inside the first "it" I'm just logging into my system by clicking on the different data fields and accessing the section of the web that I'm interested in.

it('Open Simulations', () => {
      cy.visit('/') //Loads the first page
      cy.get('button[id="onetrust-accept-btn-handler"]').click() //Accepts Cookies
      cy.get('.input-box-main-field.required').type('mockuser') //Type the user
      cy.get('input[type=password]').type('mockpwd{enter}') //Type the password
      cy.get('.spinner').should('not.exist') //waits until loading spinner is gone
      cy.visit('/simulacion/nueva') //opens simulations
      cy.scrollTo('right') //scrolls to simular travel button
      cy.get('.sc-EHOje.fgNeQB').eq(7).click() //Clicks on simular
      cy.get('.spinner').should('not.exist') //waits until loading spinner is gone
    })

After this a screen will appear waiting for data submission, this screen needs 4 different data: Destination, Amount of passengers, Date of arrival, Date of Departure.

it('Fill Simulation', () => {
      
      cy.get('.input-box-main-field').contains('Seleccione un destino de viaje').click()//opens drop down menu
      cy.get('ul>li').eq(0).click()//selects 1st element aka Spain
      cy.get('.input-box-main-field.required').type('2')//Setting pasenger number
      cy.get('.input-box-main-field').eq(3).type(dayjs().format('DD/MM/YYYY'))// settign todays date as return
      cy.get('.main-button-text').contains('CONTINUAR').click()//Continue
      cy.get('.spinner').should('not.exist')
    })

After this, the app will validate the data fields and then send the API a post request with the data, so an estimate may be returned. When testing this by myself there is no problem, the post request goes through and I get my result back. When doing it through this Cypress code a problem appears, the auth key is missing, so my backend won't allow me to make a post request. I've no idea why this is happening, the auth key is stored on LocalStorage.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!