Skip to main content

Specify home directory for zipping Cypress tests

Learn about setting a custom home directory in your Cypress configuration file to get access to all your files during a run at BrowserStack.

Overview

When you trigger a Cypress build on BrowserStack, the BrowserStack Cypress CLI begins the execution by reading the Browserstack.json file. From the configuration file, the CLI reads the location of your cypress.json file and accordingly zips and uploads the entire directory where the cypress.json file is located.

If your Cypress build requires files which are not in the same directory as the cypress.json file, then you can specify a different home directory by using this feature to zip and upload the test suite to BrowserStack.

Note: If your cypress.json file is not in the same directory as the browserstack.json, you need to specify the path to the cypress.json in the browserstack.json file. Check out how to specify Cypress config files in the browserstack.json file.

Consider the folder structure displayed in the following image:

Sample Folder Structure

When you trigger the Cypress build, BrowserStack will only upload Folder B as it contains the cypress.json file.
As a result, only Test 2 will pass. Test 1 will fail because the dependent files required for it were in Folder A which was not uploaded.

To avoid your test being failed, you need to specify the root directory as the home_directory in the browserstack.json file.

Set the home directory in browserstack.json

Set the home_directory key within the run_settings object in the browserstack.json file:

browserstack.json
...
{
...,
"run_settings": {
    ...,
    "cypress_config_file": "<path/to/your/cypress_config_file>.json",
	"home_directory": "</path/to/your/projects/root_directory/name_of_root_directory>",
    ...,
},
...
}
...
Note: Please make sure that your cypress_config_file is located within the folder structure of your home_directory.

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