3
votes

I am trying to set different environment for my test suite in Cypress. When I provide Cypress this dictionary as a JSON, Cypress throws error. Its unable to read the JSON (its unable to read users array (works fine without it)).

{
  "baseUrl": "https://staging-econsole.esihs.net/",
  "env": {
    "platform": "staging",
    "api_server": "https://pro.esiapi.io",
    "users": [
        {
            "name": "test01",
            "email": "[email protected]"

        },
        {
            "name": "test02",
            "email": "[email protected]"
        }
    ]

  }
}

Or can anyone suggest whats the best way to configure different users in Cypress. I have read there documentation and I want to configure different users via plugin.

1
please post your code how you are trying to read array of objects.Kushal
I am following the documentation provided here read env via plugin. I am reading a file called staging.json.trickster
okay, so you mentioned you are able to work without .json arrays right? So there seems no issue in reading json file only issue seems to be how you are reading array from it.Kushal
@kushal.8 Yup when I pass it as a string its just not very readable. Some people in my team are shifting from manual to automation testing and such long strings make them panic.trickster

1 Answers

3
votes

Environment variables are strings, so just pass in the stringified version of your object