Frontend Robot can be easily integrated with most build systems or CI/CD platform thanks to smart triggers. A Smart trigger is a URL that can be called from an external system to start the execution of a test suite.
Why are they called smart you may ask? That’s because they are able to detect the platform that is invoking the trigger and automatically extract some extra information to run the suite or integrate with other platforms. An example is the Netlify integration where the smart trigger can parse the Github commit hash passed by Netlify allowing Frontend Robot to attach the test results to the commit on Github.
To get the smart trigger for a test suite, navigate to that suite and then go to the Settings tab:
Scroll down to the Smart Trigger section and click Generate Smart Trigger URL:
The URL that will appear is the smart trigger for the test suite. You can also click on the cRUL tab to get a cURL
command you can copy/paste in your build script to trigger the test suite run at the end of your deployments.
Smart Triggers allow you to pass variables to the test suite, overriding or complementing any existing test suite variables.
To pass a set of variables, simply specify the variables
query parameter or the variables
request body property. In both cases the variables must be specified using a valid JSON array having the following structure:
[{
"name": "variable_name",
"value": "any valid JSON primitive"
}]
Example using the request body (variables passed is todo_text=Hello
):
curl -d '{"variables": [{"name": "todo_text", "value": "Hello"}]}' -H "Content-Type: application/json" -X POST "https://api.frontendrobot.com/v1/webhooks/runSuite?t=xxxxxxxxxx"
Example using query parameters (variables passed is todo_text=Hello
):
curl -X POST "https://api.frontendrobot.com/v1/webhooks/runSuite?t=xxxxxxxxxx&variables=%5B%7B%22name%22%3A%20%22todo_text%22%2C%20%22value%22%3A%20%22Hello%22%7D%5D"
Note: Remember to encode the JSON string when using query parameters to pass variables, as shown above.
Note: The variables specified in the query will be appended to the variables specified in the request body. This means that the variables in the query will override those in the body if they have the same name.
In many CI configurations, it’s useful to know the status of a test suite session. For example, you may want to automatically trigger a deployment to production only if all the smoke tests on staging have passed.
Every Frontend Robot smart trigger invocation will return a JSON object such as the following:
{
"started": true,
"testSuiteSessionId": "NGNE4DLkC9CGnl0m"
}
You can pass the testSuiteSessionId
to the /v1/webhooks/getTestSuiteSessionStatus
API to retrieve the status for that particular test suite session. You will also need the token (the t
query parameter of the smart trigger) that you use to invoke the smart trigger for that particular test suite.
This is what an invocation of the API looks like (using curl
):
curl "https://api.frontendrobot.com/v1/webhooks/testSuiteSessionStatus?t=sxGKIxk2q6CgaWfm0x&testSuiteSessionId=NGNE4DLkC9CGnl0m"
Which will return a string representing the current status of the test suite session. It can be one of the following:
queued
running
passed
error
failed