This page provides a walkthrough on how to run Cypress tests locally and on Sauce Labs.
- A Sauce Labs account (if you don't have one, start a free trial)
- Download and install
- Ensure you've met the prerequisites outlined in the Testrunner Toolkit documentation
Before you begin running cypress tests, you must configure
saucectl if you plan to view test results on the Sauce Labs dashboard or running tests on the Sauce Labs VMs:
Configure your Sauce Labs credentials:
via system environment variables:bash exampleexport SAUCE_USERNAME=<your sauce labs username>export SAUCE_ACCESS_KEY=<your sauce labs access key>
saucectl configure:saucectl configure
This command generates a
credentials.ymlfile:example credentials.ymlusername: <your saucelabs username>accessKey: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxsource: saucectl configure
Do NOT commit
It should go without saying, but do not publicly expose your
credentials.ymlfile over the internet. Make sure you add this file to your
.gitignorefile, as you should only use it locally.
cypressframework. This command generates the default
cypress.jsonfile, and an example cypress test:INF Start New CommandChoose a framework:PuppeteerPlaywrightTestcafe❯ Cypress
Want to use your existing Cypress tests?
If you have existing cypress tests,
saucectlprompts you to potentially overwriting the
cypressdirectory and the
If you want to edit the configuration manually select "No" and visit the configuration documentation for more details.
Choose a Sauce Labs data center location:INF Start New CommandChoose a framework: CypressChoose the sauce labs region:❯ us-west-1eu-central-1
The following steps outline how to run your cypress tests on your local machine with the containerized solution, Testrunner Toolkit:
Run your cypress tests using
dockermode by modifying
orsuites:- name: saucy testmode: docker
The test results display in the console like so:9:49AM INF Running version 0.23.29:49AM INF Reading config file config=.sauce/config.yml9:49AM INF Starting local runner9:49AM INF Setting up test environment9:49AM INF File mounted from=./tests/ to=/home/seluser/tests9:49AM INF Using credentials from environment variables9:49AM INF Starting tests> firstname.lastname@example.org test /home/seluser> ./bin/cypressIt looks like this is your first time using Cypress: 4.9.0[18:49:28] Verifying Cypress can run /home/seluser/.cache/Cypress/4.9.0/Cypress [started][18:49:33] Verified Cypress! /home/seluser/.cache/Cypress/4.9.0/Cypress [title changed][18:49:33] Verified Cypress! /home/seluser/.cache/Cypress/4.9.0/Cypress [completed]Opening Cypress...================================================================================(Run Starting)
You can also troubleshoot any issues with the --verbose flag.
A Sauce Labs job link appears in the console where you can verify the results in the Sauce Labs dashboard:Preparing assets for tests/home.tree.test.jsOpen job details page: https://app.saucelabs.com/tests/8fb13276b39f40c2b05048776bcaeaf6
The following steps outline how to run your cypress tests using Sauce Labs virtual machines:
Run your cypress tests with the following
orsuites:- name: saucy testmode: sauce
For more information regarding the
saucectlparameters, including how to increase your VM concurrency, please visit the configuration documentation.
Watch test runs in real-time, or verify the results in the Sauce Labs dashboard:
Running Tests with a Local App
If you plan to run your cypress tests with either of the following scenarios:
localhostapp running on your host machine
- An app running locally in a CI pipeline
- An app running on a local app server in a private network
Please review the following documentation section for further details.
Below are some additional topics related to using Cypress with Sauce Labs.
Please visit the Configuration page to learn more about
config.yml and the specific fields and properties:
Please visit our CI integrations page for more information about how to run your tests in the following CI platforms: