Last weekend, I was setting up a Cypress test pipeline in GitLab for Toph for the 5th time.
I have no idea why this pipeline keeps breaking over time. It’s like bread left in the open. Cypress is such a fantastic end-to-end testing tool. But it seems to need a lot of extra love.
Something that I needed to do was, in the CI/CD script, wait for Toph to start handling HTTP requests before starting Cypress.
Take the following as an example:
./serverin the background
- Wait for
./serverto start handling HTTP requests
- Run Cypress tests
In the case of Toph, I could have added a
sleep 1 after starting Toph’s web server and called it a day.
But it didn’t sit right with me. If the start-up time increases in the future or due to external reasons, the test will fail.
Instead, I added a one-liner in the GitLab CI/CD script that uses
curl to wait for Toph to start handling HTTP requests.
For the example above, it would look like this:
The second line in the script will block until
curl receives an HTTP response from
comments powered by Disqus