3

I am trying to run my cypress tests when building a project through Travis CI. I am installing cypress fine, however, I was then getting the following error:

codeI have looked online and in cypress official documentation and the method that they recommend fixing this issue by adding the following into my package.json:

"test:ci": "start-server-and-test http://localhost:3000 cy:run"

cy:run in this case being cypress run. However, when I run this, it does build the server however it then does not seem to run the tests afterwards. It just freezes on the build.

I then call this script within my travis.yml file as shown:

  - npm run test:ci

I also have the following as my before_install and install object:

before_install:
  - npm i -g npm@5
  - npm i -g firebase-tools
  - npm i -g @angular/cli
  - npm cache verify

install:
  - npm i
  - npm ci

To clarify - the desired results is that when running Cypress through Travis, the local server (my baseUrl) is run and then the tests are carried out.

10 Rep
  • 2,217
  • 7
  • 19
  • 33
Jm3s
  • 556
  • 2
  • 12
  • 24
  • have the same issue on gitlab ci. – ElectRocnic Jul 31 '19 at 20:34
  • @ElectRocnic I managed to solve this issue by running a http-server and not local host like so: `"http-server dist -p 3000 -c-1 --cors"` – Jm3s Aug 02 '19 at 08:53
  • Thanks, but my setup seems to be completely different from yours, because I already was using nginx as my http-server, and still had the same problem. My problem was solved through https://stackoverflow.com/a/48288560/3433137 . My setup was a gitlab-ci using dind. I could not connect to my served app, as the exposed port 8000 was not exposed to my runner, but to the service defined in the gitlab-ci.yml. Thus I could connect with docker:8000 instead of localhost:8000 – ElectRocnic Aug 06 '19 at 13:46

1 Answers1

1

Use "baseUrl":"http://host.docker.internal:3000" in your cypress.json

Metawaa
  • 306
  • 3
  • 15