Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication with Environment Variables returning error #879

Open
dudeOFprosper opened this issue Oct 1, 2024 · 0 comments
Open

Authentication with Environment Variables returning error #879

dudeOFprosper opened this issue Oct 1, 2024 · 0 comments

Comments

@dudeOFprosper
Copy link

I am attempting to use Environment Variables, inside of my .env file, to load my BROWSERSTACK_USERNAME & BROWSERSTACK_ACCESS_KEY credentials.

If I add my Browserstack credentials into the auth object within the browserstack.json file, I have no issues authenticating and running my Cypress tests. But if I move these values in my BROWSERSTACK_USERNAME & BROWSERSTACK_ACCESS_KEY variables inside of my .env file and run the same command, I am getting this error:

{
  message: "Cannot read properties of undefined (reading 'username')",
  stack: "TypeError: Cannot read properties of undefined (reading 'username')\n" +
    '    at /Users/billpond/code/comparecredit/packages/cc-www/node_modules/browserstack-cypress-cli/bin/helpers/getInitialDetails.js:12:33\n' +
    '    at new Promise (<anonymous>)\n' +
    '    at exports.getInitialDetails (/Users/billpond/code/comparecredit/packages/cc-www/node_modules/browserstack-cypress-cli/bin/helpers/getInitialDetails.js:8:10)\n' +
    '    at /Users/billpond/code/comparecredit/packages/cc-www/node_modules/browserstack-cypress-cli/bin/commands/runs.js:87:86\n' +
    '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)'
}

When debugging, I have logged out my "process.env" value in the setUsername function in the util.js file. When I did this, I do not see any of my .env values within that process. It seems like the only values included were the typical node values inside of the process: https://pastebin.com/syj8rRAN

I have tried both node versions v18.18.2 and v20.17.0 and ran into the same issue. To run this code, I have been running a command in my package.json that is set to "e2e:browserstack": "browserstack-cypress run"

I am trying to follow the documentation mentioned here: https://www.browserstack.com/docs/automate/cypress/authentication

Thank you so much in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant