CI/CD Platform Integration with saucectl
Using the saucectl
CLI, you can execute API tests and interact with Sauce Labs API Testing.
What You'll Need
- A Sauce Labs account (Log in or sign up for a free trial license).
- Your Sauce Labs Username and Access Key.
- An existing API Testing Project. For details on how to create one, see API Testing Quickstart.
Step 1: Create a Webhook
To utilize saucectl
functionalities, you'll need to generate a webhook for your API Testing Project. Once generated, you'll need only the name of your API Testing Project.
To generate a webhook:
- Log in to Sauce Labs, then click API Testing.
- Navigate to your Project and select the WebHooks tab.
- Select Create Hook.
- Enter a Hook Name for your webhook (Description is optional), then click Save.
- The generated Hook URL will then appear. Your Sauce Labs username, Sauce API Testing endpoint, and
{hook_id}
will populate automatically. For security reasons, you'll need to add your own access key.
Step 2: Install saucectl
In a terminal shell, run the install command from your chosen saucectl
home directory.
npm install -g saucectl
Step 3: Link Your Sauce Labs Account
saucectl
requires access to a valid Sauce Labs account.
saucectl
detects your Sauce Labs credentials environment variables and prioritizes them over values in the credentials.yml
file when both are present. If you have set them, you may skip this step. Not sure if you have them set? Run the following command to check:
echo $SAUCE_USERNAME
echo $SAUCE_ACCESS_KEY
If a value is returned for both variables, they are set.
Run the
configure
command:saucectl configure
Enter your Sauce Labs Username and Access Key at the prompts.
Step 4: Clone the API Testing Project
- HTTPS
- SSH
git clone https://github.com/saucelabs/saucectl-apitest-example.git
git clone git@github.com:saucelabs/saucectl-apitest-example.git
Step 5: Run Tests
Navigate to the root of the API Testing project you just cloned, then use the run
command to execute the sample test included with the saucectl
example.
cd saucectl-apitest-example
saucectl run
The console displays the executing tests, distinguishing which mode is running.
The results are available immediately following test completion in your Sauce Labs account.
More Information
See saucectl YAML Configuration for more configuration options.