2023-03-22

How can I passing multiple Cypress environment variable in CLI?

I have the following configuration in my Cypress cypress.config.js

 env: {
    baseUrl: "https://home.abc.com",
    token_url: "https://home.abc.com/api/token",
    username: "",
    password: ""
  },

However, when I pass the following command in CLI, it always results in an unauthorized issue from my endpoints.

yarn cypress run --env username=admin,password=samplepassword

Things work great when I directly assign a username and password with its value inside the config file but I trying to store credential details inside my code.

I tried to pass only one environment variable for testing and it work perfectly.

cypress.config.js

 env: {
    baseUrl: "https://home.abc.com",
    token_url: "https://home.abc.com/api/token",
    username: "",
    password: "samplepassword"
  },

CLI Command yarn cypress run --env username=admin



No comments:

Post a Comment