Twilio Video React App is an open source application provided by Twilio as a reference to those developing video based application. If you are using this as a starting point, then the script provided here is a great way to introduce testing automation to the Twilio Video React framework you are using.
The Twilio code is maintained on GitHub (here).
Preparation
Deploy the Twilio application as explained on the GitHub page of the project.
Out of the box, you should get something like this in terms of user experience:
Using the test script
In testRTC, create a new test script:
- Copy the code from the bottom of this article to your test script (or use the existing sample in your account)
- Decide the number of probes you want to use
- Concurrent probes: 2 concurrent probes would be good starting point – keep it at an even number (you need pairs of probes for this)
- Set the Session size to the number of concurrent probes for this sample
- Replace the Service URL of the script with the URL where your Twilio Video React App server is installed
Test execution
Run the script. It does everything for you.
If you want, you can join the same room from your browser once you see the URL in the progress messages of the test.
Test script codevar agentName = process.env.RTC_AGENT_NAME;
var agentSession = Number(process.env.RTC_SESSION_IDX);
var agentSessionName = process.env.RTC_SESSION_NAME;
var agentNumber = process.env.RTC_AGENT_NUM;
var sec = 1000;
var roomUrl = process.env.RTC_SERVICE_URL;
client
.pause(agentNumber * 500);
client
.rtcInfo("testRTC agent start - agent: %s room: %s", agentName, roomUrl)
.url(roomUrl)
.waitForElementVisible('#input-user-name', 120 * sec)
.pause(300) //wait for page render
.setValue('#input-user-name', agentName.replace(/-/g, ''))
.pause(300)
.setValue('#input-room-name', agentSessionName.replace(/-/g, ''))
.click(".MuiButtonBase-root.MuiButton-root")
.pause(5000)
.useXpath()
.waitForElementVisible("//*[text()='Join Now']", 120 * sec)
.pause(300)
.click("//*[text()='Join Now']")
.rtcProgress("In " + roomUrl)
// Give some time to collect media stats
.pause(60 * sec)
.rtcScreenshot('mid-call')
.pause(60 * sec);