Specify spec timeout
Learn how to specify a timeout for your Cypress test specs to stop tests from failing due to issues in spec files.
Introduction
On BrowserStack, when you run your Cypress tests, if there are issues in your spec file, the test session continues to run and eventually blocks a parallel that could be used by another spec. To avoid this issue and optimize build performance, set a spec timeout for your Cypress tests.
You can set the timeout either using the browserstack.json
file or the BrowserStack Cypress CLI.
In this guide, you will learn:
- The importance of spec timeout
- Set a timeout in browserstack.json
- Set a timeout using the CLI
- Points to remember
The importance of spec timeout
BrowserStack allows all specs to run for a default duration of 30 minutes, after which your test run is forcibly stopped. If there exist any issues with any of your test spec leading to Cypress hanging, the spec would be forcibly killed by BrowserStack after the timeout duration has elapsed. You can set a spec_timeout
between 1
and 120
minutes.
Set a timeout in browserstack.json
Use the spec_timeout
key within run_settings
option to set the timeout duration for the spec files.
Key | Accepted values |
---|---|
spec_timeout |
Accepts string and numeric value ranging from 1 to 120 minutes. Default timeout duration is 30 minutes. |
For example:
{
...
"run_settings": {
...
"spec_timeout": 10
...
}
...
}
{
...
"run_settings": {
...
"spec_timeout": "10"
...
}
...
}
Set a timeout using the CLI
Use the --spec-timeout
argument in the CLI to set a timeout as follows:
Argument | Shorthand | Accepted values |
---|---|---|
--spec-timeout |
-t |
String and numeric value ranging from 1 to 120 minutes. Default timeout duration is 30 minutes. |
For example:
# Set a spec timeout of 10 minutes using a numeric value
browserstack-cypress run --spec-timeout 10
# Set a spec timeout of 10 minutes using a string value
browserstack-cypress run --spec-timeout "10"
Points to remember
Before you set a timeout for your spec files, note the following points:
- For any value set for the timeout apart from numeric or string value, BrowserStack sets the default timeout of 30 minutes.
- Any timeout value set using the CLI takes precedence over the values set in the
browserstack.json
file.
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
- RESOURCES
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!