I have an alias defined in 1 test and I would like to use the result in a different test:
it('fills in the login form', () => {
cy.intercept({
method: 'POST',
url: `${Cypress.env('apiURL')}/api/v1/user/login`,
}).as('login');
cy.get('[data-cy="inputEmailAddress"]').type(company.users[0].email);
cy.get('[data-cy="inputPassword"]').type(company.users[0].password);
cy.get('[data-cy="buttonLogin"]').click();
});
it('does stuff', () => {
cy.get('@login')
.its('response')
.then((res) => {
expect(res.statusCode).to.eq(200);
});
});
But I'm getting an error:
cy.get() could not find a registered alias for: @login. You have not aliased anything yet.
Any suggestions on how to make the alias available in a different test?