Run Tests in CI/CD

Learn how to run your Cypress tests in your CI/CD pipelines.

Running tests in CI/CD is very similar to the way you run the tests from your local machine.

Note: You don’t have to install Cypress or any of the npm packages on your CI machine. We will install them on our machines before running the test automatically.
  1. Clone your project / tests repository
  2. Install the BrowserStack-Cypress CLI
  3. Optionally, set up your application server if needed (for example, you want to set up a local server for every PR)
  4. Run your tests on BrowserStack. Optionally, set environment variables. See how to run tests in parallel.
  5. Optionally, receive updates about the test runs using polling or callback

Set environment variables

You can specify the auth and local-testing related settings via environment variables as well, instead of hard-coding them in browserstack.json. This makes it easier for you to test using the appropriate settings depending on whether you are running from your local machine or from your CI setup.

The CLI currently reads config from the following environment variables:

Env variable Accepted values
BROWSERSTACK_USERNAME Your BrowserStack username
BROWSERSTACK_ACCESS_KEY Your BrowserStack access key
BROWSERSTACK_LOCAL true if you want to use Local testing
BROWSERSTACK_LOCAL_IDENTIFIER The Local identifier you want to use
Note: If you are using our CI/CD plugins, these environment variables are automatically set depending on how you configured the plugin. Learn more about our CI/CD plugins here: Jenkins, Bamboo, TeamCity, Azure Pipelines, Circle CI, Bitbucket Pipeline, Travis CI, GitHub Actions.

Retrieve build details after running

Starting from v1.4.0, the CLI now generates a log/build_results.txt file that contains 2 lines with the details of the build ID, and the dashboard URL like below:


Set up your application server

Set up an application server like you normally would (for example, you probably would host the app on localhost:3000).

But, additionally, you’ll have to set up a Local Testing connection. Make sure the local testing connection is established before running the tests, and is alive at least until all the tests are done running. In most cases, this means that:

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked

Thank you for your valuable feedback