Skip to main content
Cypress 10 support is here! Upgrade your BrowserStack Cypress-CLI to v1.18.0 and start testing. Try now!

Exclude files from test uploads

Learn how to exclude specific files when uploading your tests to BrowserStack

When you running Cypress tests using the run command, the CLI zips the folder where your Cypress configuration file resides (as defined in cypress_config_file).

Note: Check out how to specify spec files to run if you are looking for a way to run a subset of tests on BrowserStack, using thespecs option.

We only access the uploaded files to run your tests and troubleshoot support tickets, however, you may want to exclude files that your tests do not require. This usually helps if:

  • File zipping fails because of unsupported files (we only support test & media files at the moment)
  • The test upload fails or takes longer than a couple of minutes
  • The generated zip file is more than 1 GB in size
  • Your test uploads are failing because of network connection issues
  • You are zipping unnecessary files like node_modules/*

You can exclude files from test uploads in two ways:

  1. Using the exclude key in your configuration file
  2. Using the CLI’s --exclude arg

Using browserstack.json

You can use the exclude key in run_settings option to exclude specific files when uploading your tests to BrowserStack.

Key Accepted values
exclude An array of patterns (file paths or regexes) that match the files that you want to exclude

For example:

browserstack.json
{
  ...
  "run_settings": {
    ...
    "exclude": ["some-folder/test.js", "static/*.pdf"]
    ...
  }
  ...
}

Using the CLI

You can use the following args while running the tests using the run command:

Arg Shorthand Accepted values
--exclude -e Comma separated patterns (an exact path or a regex) of the files

For example:

Command Line
# Exclude just the some-folder/test.js file
browserstack-cypress run --sync --exclude "some-folder/test.js"

# Exclude the abcd folder
browserstack-cypress run --sync --exclude "some-folder/*"

# Exclude every pdf in the some-folder folder
browserstack-cypress run --sync --exclude "some-folder/*.pdf"

# Exclude every pattern
browserstack-cypress run --sync --exclude "some-folder/*.pdf,some-folder/test.js"

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