Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cypress could not verify that the server set as your 'baseUrl' is running:

I can reach from my computer with web browser to xxxx.com:8089 which is running on a container too but different remote machine. Everything is fine. My cypress.json

"baseUrl": "http://xxxx.com:8089" is this.

I am trying to run docker container to run tests with Cypress :

docker run --rm --name burak --ipc="host" -w /hede -v         /Users/kurhanb/Desktop/nameoftheProject:/hede'  cypress  /bin/bash -c    cypress run --browser chrome && chmod -R 777 . --reporter mochawesome --reporter-options --reportDir=Users/kurhanb/Desktop/CypressTest overwrite=false

It gives me :

Cypress could not verify that the server set as your 'baseUrl' is running:

http://xxxx.com

Your tests likely make requests to this 'baseUrl' and these tests will fail if you don't boot your server.

So basically, I can reach from my computer but container can not ?

like image 651
Burak Kurhan Avatar asked Dec 28 '18 14:12

Burak Kurhan


3 Answers

Cypress is giving you that error because at the time that Cypress starts, your application is not yet ready to start responding to requests.

Let's say your application takes 10 seconds to set up and start responding to requests. If you start your application and Cypress at the exact same time, Cypress will not be able to reach your application for the first ten seconds. Rather then wait indefinitely for the app to come online, Cypress will exit and tell you that your app is not yet online.

The way to fix this problem is to make sure that your web server is serving before Cypress ever turns on. The Cypress docs have some examples of how you can make this happen: https://docs.cypress.io/guides/guides/continuous-integration.html#Boot-your-server

like image 178
Zach Bloomquist Avatar answered Nov 12 '22 08:11

Zach Bloomquist


I got the "Cypress failed to verify that your server is running" problem despite being able to access the site through a browser. The problem was that my

/etc/hosts

file did not include a line:

127.0.0.1 localhost
like image 34
Samuel Åslund Avatar answered Nov 12 '22 09:11

Samuel Åslund


In your CICD pipeline, make sure your application is up and running before Cypress.

Using Vue.js app as example, use following commands in CICD pipeline scripts:

npm install -g wait-on
npm run serve & wait-on http://localhost:8080
cypress run
like image 1
Jerry Chong Avatar answered Nov 12 '22 09:11

Jerry Chong