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?