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

160
Views
setLocalStorage is not working on cypress test

I have a problem with token.

I have loginCommand.

Cypress.Commands.add('login', (user, password) => {
  cy.request('POST', `${Cypress.env('API')}/auth/login`, {
    email: Cypress.env(user),
    password: Cypress.env(password),
  })
    .its('body')
    .then(res => {
      cy.log('res:', res);
      cy.setLocalStorage('token', res.token);
    });
});

I am trying to add new offer. And this is the test case.

it('can create an projectOffer C232 C233 C234 C235 C236', () => {
  //cy.seed(token);
  cy.fixture('offerA').as('offerA');
  cy.login('testEmail', 'testPwd');
  cy.visit(base);
  const customerRef = `create offer test ${new Date().toISOString()}`;
  cy.fixture('offerA').then(offerA => {
    cy.createOffer(offerA, customerRef);
  });
});

and also this is the related part of my code.

Cypress.Commands.add('createOffer', (offer, offerName) => {
  cy.get('[data-testid=app-toolbar-item]').click();

The error is

[data-testid=app-toolbar-item], but never found it.

In the application tab I see that my token is not there

What can I do for fixing this?

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!