Skip to content

Authentication with Environment Variables returning error #879

Open
@dudeOFprosper

Description

@dudeOFprosper

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions