Skip to main content

Specify home directory for zipping Cypress tests

Learn how to set a custom home directory in your Cypress configuration file to get access to all your files when running a test on BrowserStack.

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 configuration file and accordingly zips and uploads the entire directory where the configuration file is located.

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

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

Consider the sample folder structure displayed in the following image for Cypress v10:

Sample Folder Structure

When you trigger the Cypress build, BrowserStack will only upload Folder B as it contains the cypress.config.js 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.

For Cypress v9, the configuration file is cypress.json in Folder B, whereas the tests specs will be Test 1.cy.js, and Test 2.cy.js.

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": {
    ...,
	"home_directory": "</path/to/your/projects/root_directory/name_of_root_directory>",
    ...,
},
...
}
...

Ensure that your Cypress configuration 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
Download Copy