testRTC allows you to set your own customer environment variables in running test scripts via the APIs. This gives more flexibility when executing the commands from CI/CD or other test suite environments.
You can use environment variables to:
- Decide which URL to use (when launching tests on heroku machines for example)
- Pick specific room id’s or names in a test
- Decide on usernames or passwords
- Etc
Example
Lets assume we want to create a custom variable to pick the room id for the user to join in a test.
We will call it ROOM_ID.
Inside our test script, we can refer to it as process.env.ROOM_ID, and use it in
whatever fashion we need.
Like:
client.rtcSetAdditionalInfo("process.env.ROOM_ID " + process.env.ROOM_ID);
To populate ROOM_ID with a value, we need to add our environment variable as an array of
tuples. Something like
this:
"environmentVariables": [
{
"variable": "ROOM_ID",
"value": "room1"
}
]
Invoking it through cURL would be something like this:
curl -X POST "https://api.testrtc.com/v1/tests/{{TESTID}}/run" -H "accept: application/json" -H "apikey: {{APIKEY}}" -H "Content-Type: application/json" -d "{ \"environmentVariables\": [{ \"variable\": \"ROOM_ID\", \"value\": \"room1\" } ]}"