powerful-orange-86819
07/11/2022, 10:08 AMjs
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);
});
});