CLI Reference

A list of all the commands and arguments supported by the BrowserStack-Cypress CLI

Here is a list of all the CLI args you can use to run tests, stop the ones that are running, and retrieve build information:

Generate configuration file

Use the init command to generate a sample browserstack.json config file.

You can optionally specify the filename you want to use for the BrowserStack config file.

For example:

Command Line
# Create a sample configuration file for configurations and capabilities
browserstack-cypress init

# Create a sample configuration file as browserstack.staging.json
browserstack-cypress init browserstack.staging.json

Additional arguments that are available with the init command are:

Arg Accepted values
--path Path to the directory or folder where you need the browserstack.json file to be generated. Make sure that the specified folder exists before using this parameter.

Default: ./ (the current directory)

Run tests

You can start running your test build using the following command.

Command Line
browserstack-cypress run

Additional arguments that are available with the run command are:

Arg Shorthand Accepted values
--sync - No values required. Use this flag to run the tests synchronously.
--parallels -p The integer number of parallels to use while running the build
--build-name -b The build name to use for this build
--username -u Your BrowserStack username
--key -k Your BrowserStack access key
--headed - Optionally, pass this to run your tests in a browser in headed mode as opposed to headless (with some performance degradation)
--config-file --cf Path to the BrowserStack config file.

Default: ./browserstack.json
--cypress-config-file --ccf Path (absolute or relative to browserstack.json) to the Cypress config file
--specs -s Comma separated patterns (an exact path or a regex) for your spec files
--env - Comma separated key=value pairs of the environment variables to set before running your tests
--exclude -e Comma separated patterns (an exact path or a regex) of the files you want to exclude

Example:

Command Line
browserstack-cypress --cf <path-to-browserstack.json> run --sync --parallels 5 <any-other-args>

Generate build report

If you didn’t run the build in sync mode (using --sync), the HTML and JSON files with the build run summary are not automatically created. You can use the generate-report command to generate the HTML and JSON instead.

Command Line
browserstack-cypress generate-report <build-id>

Additional arguments that are available with the generate-report command are:

Arg Shorthand Accepted values
--username -u Your BrowserStack username
--key -k Your BrowserStack access key
--config-file --cf Path to the BrowserStack config file.

Default: ./browserstack.json

Example:

Command Line
browserstack-cypress --cf <path-to-browserstack.json> generate-report <build-id>

Get the build information

In case you want to get information on the build you can use the build-info command:

Command Line
browserstack-cypress build-info <buildId>
Sample response
[2/20/2020, 3:01:52 PM]  Getting information for buildId 06f28ce423d10314b32e98bb6f68e10b0d02a49a
[2/20/2020, 3:01:52 PM]  Reading browserstack.json from /browserstack.json
[2/20/2020, 3:01:54 PM]  Build info for build id:
 {
  "build_id": "06f28ce423d10314b32e98bb6f68e10b0d02a49a",
  "framework": "cypress",
  "status": "done",
  "input_capabilities": {
    "devices": [
      "OS X Catalina-chrome69",
      "OS X Catalina-chrome66"
    ],
    "testSuite": "15f90b540b8cbc47929782f35bb7db20fe1c4709",
    "customBuildName": "cypress build",
    "local": false,
    "localIdentifier": null,
    "callbackURL": null,
    "projectNotifyURL": null,
    "project": "test"
  },
  "start_time": "2020-02-20 09:28:35 UTC",
  "device_statuses": {
    "success": {
      "OS X Catalina-chrome69": "Success",
      "OS X Catalina-chrome66": "Success"
    },
    "error": {}
  },
  "test_suite_details": {
    "url": "bs://15f90b540b8cbc47929782f35bb7db20fe1c4709",
    "name": "tests.zip",
    "size": 354
  },
  "duration": "33 seconds",
  "devices": {
    "OS X Catalina-chrome69": {
      "session_id": "3b4038cbbc55d34c1b33c930f3417c7c534c25dd",
      "status": "done",
      "test_status": {
        "failed": 0,
        "success": 3,
        "queued": 0,
        "ignored": 0
      }
    },
    "OS X Catalina-chrome66": {
      "session_id": "fbda8eb5a9eeb7823a9ef7be1a42213c568197e8",
      "status": "done",
      "test_status": {
        "failed": 0,
        "success": 3,
        "queued": 0,
        "ignored": 0
      }
    }
  }
}

Note that each browser version represents a session. It is advised to validate your account’s parallel limit before running multiple versions.

Additional arguments that are available with the build-info command are:

Arg Shorthand Accepted values
--config-file --cf Path to the BrowserStack config file.

Default: ./browserstack.json

Example:

Command Line
browserstack-cypress --cf <path-to-browserstack.json> build-info <buildId>

Stop a running build

In case you want to stop a running build, you can use the build-stop command:

Command Line
browserstack-cypress build-stop <buildId>

Additional arguments that are available with the build-stop command are:

Arg Shorthand Accepted values
--config-file --cf Path to the BrowserStack config file.

Default: ./browserstack.json

Example:

Command Line
browserstack-cypress --config-file <path-to-browserstack.json> build-stop <buildId>

Disable usage reporting

The CLI collects anonymized usage data including the command-line arguments used, system details and errors that you get so that we can improve the way you run your Cypress tests on BrowserStack. Usage reporting is enabled by default - you can disable usage reporting by using the --disable-usage-reporting flag. You can also do this by setting the disable_usage_reporting option to "true" in browserstack.json.

Command Line
browserstack-cypress --disable-usage-reporting <your-commands>

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
Talk to an Expert