I use support/commands.js from cypress to set the functions for the requests to the API or in order to login on the test files.
On my commands.js I have this function.
Cypress.Commands.add("login", () => {
cy.request({
method: "POST",
form: true,
url: "baseUrl/api/v1/auth/login",
headers: {
"Content-Type": "application/json",
},
body: {
email: "testUserEmail",
password: "testUserPassword",
},
})
.its("body.data")
.should("exist")
.then((session_token) => {
cy.setLocalStorage("default_auth_token", session_token);
cy.setCookie("rememberMe", "false");
token = session_token;
});
});
I want to access the variables on my cypress.json in order to set baseUrl, user and password there and not all spread on my commands.js.