Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & Test Observability

Using Local Testing in CI/CD

A practical guide to help you use Local Testing successfully in your CI/CD pipelines.

This document will help you set up the Local Testing connection with an unique identifier and also explain how you can run it in the daemon mode, which is required in the CI/CD setup.

Warning: Running your Cypress tests on BrowserStack is completely async, and you will have to make sure that the Local Testing connection is established before starting the test run, and stays established until the tests completed. Run the tests in sync mode with --sync arg or learn how you can use polling to do this.

Local Testing connection with an identifier

While setting up Local Testing with CI/CD or when other Local connections might be present (for Selenium/JS tests from your account), it is advisable to set up a Local connection with an identifier.

The same identifier will be used to identify the Local Testing connection that should be used for your tests. For that, you can use the --local-identifier option while establishing the Local connection, and use the local_identifier key to mention the same in browserstack.json file.

Example:

Establish the Local Testing connection using terminal/command prompt:

./BrowserStackLocal --key YOUR_ACCESS_KEY --local-identifier CypressLocalConnection1
BrowserStackLocal.exe --key YOUR_ACCESS_KEY --local-identifier CypressLocalConnection1

And mention the same Local identifier in the browserstack.json configuration file, like this:

...
{
  "connection_settings": {
    "local": true,
    "local_identifier": "CypressLocalConnection1"
  }
}
...

Alternatively, you can set the environment variable BROWSERSTACK_LOCAL to true and another environment variable BROWSERSTACK_LOCAL_IDENTIFIER with the appropriate string you want to use as the identifier for your Local connection.

Note: The environment variables will override the options in your browserstack.json.

Starting and stopping Local Testing in daemon mode

You can use the --daemon param while using the Local binary to start and stop the connection in the background. For example:

./BrowserStackLocal --key YOUR_ACCESS_KEY --daemon start --local-identifier CypressLocalConnection1
BrowserStackLocal.exe --key YOUR_ACCESS_KEY --daemon start --local-identifier CypressLocalConnection1

Once the tests are done running, you can stop the binary that is running in the background by using the stop command as following:

./BrowserStackLocal --key YOUR_ACCESS_KEY --daemon stop --local-identifier CypressLocalConnection1
BrowserStackLocal.exe --key YOUR_ACCESS_KEY --daemon stop --local-identifier CypressLocalConnection1

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

Is this page helping you?

Yes
No

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!

Talk to an Expert
Download Copy