I am using this Cypress image in a docker-compose.yml
to run end to end tests: cypress/included:6.1.0
When the test runner starts it will verify that a server can be reached at baseUrl
. If not, it retries 3 times.
My services and web server need a little more time to start.
How can I increase the timeout and/or number of retries for this check.
Preferably, in my case I’d like a retry-until-success policy, i.e. indefinite retries/wait.
I have checked the Timeouts section and the cypress.json
documentation more generally. However none of those timeouts or retries seem to relate to this behavior.
Is there a setting for this?
TO CLARIFY: This is not a check I implemented (or want to) as part of my specs. This is, as far as I can tell so far, a feature of cyprus run
, the default command in the image. If possible I would like to configure this without adding to or revising the tests themselves.
Here is the docker-compose console output when cypress starts in the container:
cypress_1 | Cypress could not verify that this server is running: cypress_1 | cypress_1 | > http://localhost:5000 cypress_1 | cypress_1 | We are verifying this server because it has been configured as your `baseUrl`. cypress_1 | cypress_1 | Cypress automatically waits until your server is accessible before running tests. cypress_1 | cypress_1 | We will try connecting to it 3 more times... cypress_1 | We will try connecting to it 2 more times... cypress_1 | We will try connecting to it 1 more time... cypress_1 | cypress_1 | Cypress failed to verify that your server is running. cypress_1 | cypress_1 | Please start this server and then run Cypress again. cypress_1 exited with code 1
Advertisement
Answer
You should ensure your server is running before calling cypress run
using a utility like wait-on or start-server-and-test.
Cypress’s check on the baseUrl
is a final courtesy check just so you don’t run through your whole test suite on a server that is not running.
For tips on ensuring your server is running before running Cypress, check out the Cypress docs here: https://on.cypress.io/continuous-integration#Boot-your-server