https://cypress.io logo
why are you going to the page? Just use the api, m...
# e2e-testing
p
why are you going to the page? Just use the api, make the calls without redirecting to the url, also i'd recommend declaring the env in the begining like:
Copy code
js
Cypress.Commands.add("userLogin", (username, password) => {
  const env = Cypress.env(); // THIS IS HOW I DELCARE env, then accesss it with env.something
  Cypress.log({ Name: "Generating token for user: " + username });
  const options = {
    method: "POST",
    url: env.apiUrl,
    body: {
      username,
      password,
    },
  };
  cy.request(options).then((response) => {
    env.tokens[username] = response.body.access_token;
    Cypress.env(env);
  });
});