How to run a Jenkins CI with cypress e2e test for Vue SPA that has to connect to Laravel APIs?

Viewed 455

I am trying to set up Cypress end-to-end tests for a Vue SPA application that has to connect to a Laravel backend; the tests are to run in a Jenkins pipeline. This is practically straight forward in a local development environment. Basically:

  • Use docker-compose to spin up Laravel and DB
  • Use docker to spin up the SPA and then exec cypress run inside the container

However, I can't seem to think of an optimal way to set up something like that in a Jenkins pipeline. The SPA and Laravel are in separate repositories and I do not want to pull the one into the other while running the CI process; the thought itself seems messy.

So, basically, what is an optimal way to set up a Jenkins pipeline that does end-to-end cypress tests for a Vue SPA that has to connect to a Laravel API/MySQL DB?

This is my very first SO question and I apologise in advance if there are any rules I breached while creating it.

1 Answers

Cypress does not care where your BE is being hosted, it is set by your baseUrl.

Set up a deployment process for your BE repo on your Jenkins CI, which hosts the site at a subdomain of your ci server like e2e.example.com. Once your BE is deployed, then you can setup another job to deploy and test your Vue SPA.

If it was me, I would create one job and have it deploy first the latest/specified version of your BE, then deploy the frontend and run cypress. I have done this on an older project, with capistrano and jenkins and cypress, however mine was not an SPA in two repos so I did not have to do both deployments in one job.

Related