Exclude files from test uploads

Learn how to exclude files while uploading tests to BrowserStack

Warning: If you are looking for a way to run a subset of tests on BrowserStack, use the specs option instead. Learn more here: Specify spec files to run

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

While we don’t access the files that are uploaded except for running your tests and debugging your Support tickets, you may want to exclude files that your tests don’t need. This usually helps if:

  • File zipping is failing because of unsupported files (we only support test & media files at the moment)
  • The test upload is failing or taking longer than a couple of minutes
  • The generated zip file is more than 200 MB 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 specify the files that you want to be excluded while 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