Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run cypress tests in github actions, running up front-end and back-end http servers. #128

Closed
alessandroAmedei opened this issue Apr 27, 2020 · 7 comments · Fixed by #239
Closed
Assignees
Labels
released type: enhancement New feature or request

Comments

@alessandroAmedei
Copy link

Run cypress tests in github actions, running up front-end and back-end http servers.
Hi, i would like to run cypress tests on my Vue project linked to cypress dashboard in Github actions, triggered on push or pull events.
To test my application, wich is written on NodeJS at the backend and Vue in the frontend, i have to run both https server in the github workflow.
I am using cypress-io/github-action and it worked fine without running the backend server. This was my configuration:

name: End-to-end tests
on: [push]
jobs:
  cypress-run:
    runs-on: windows-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Cypress run
        uses: cypress-io/github-action@v1
        with:
          record: true
          start: npm run serve --prefix frontend/app
          wait-on: http://localhost:8080
        env:
          CYPRESS_RECORD_KEY: <key>

Now the goal is to have also a running server using:

npm run start # --> node index.js
So that i can get backend api listening on localhost:8000 (and vue in dev mode is refering to).

But i can not get that to work. I have tried various configuration like this:

name: End-to-end tests
on: [push]
jobs:
 cypress-run:
   runs-on: windows-latest
   steps:
     - name: Checkout
       uses: actions/checkout@v1

     - name: Run backend
       uses: actions/setup-node@v1
       with:
         node-version: ${{ matrix.node-version }}
         run: npm run start

     - name: Cypress run
       uses: cypress-io/github-action@v1
       with:
         record: true
         start: npm run serve --prefix frontend/nix-app
         wait-on: http://localhost:8080
       env:
         # pass the Dashboard record key as an environment variable
         CYPRESS_RECORD_KEY: <key>

The backend server runs correctly on port 8000, but then the workflow is stuck there! It doesn't continue on Cypress run because, i guess, it's waiting the end of the process.
How can i force to go at the next step after the first server is set up?

Another solution that i have tried is to use two different jobs in parallel, but also this is not working because the two servers will not stop running. Then what if cypress tests run before the two servers are up?

Can you suggest something else? Thank you!

@a7madgamal
Copy link

a7madgamal commented Jun 2, 2020

@alessandroAmedei I was going to open an issue asking for multiple https://github.com/cypress-io/github-action#wait-on keys, is this what you are also asking for?

@jarretmoses
Copy link

@alessandroAmedei dunno if its just a typo but you said your backend is running correctly on port 8000 but your ci setup is waiting on port 8080

@alessandroAmedei
Copy link
Author

@alessandroAmedei dunno if its just a typo but you said your backend is running correctly on port 8000 but your ci setup is waiting on port 8080

No, 'npm run start' runs the application on port 8000 because my Express app is running there. I found another solution. I think Github actions is really confusing and there is not clear documentation.

@davidpodhola
Copy link

@alessandroAmedei would you please share what solution you used? I would also like to run both the node.js backend and the frontend in GitHub actions, thanks.

@elie222
Copy link

elie222 commented Oct 17, 2020

@davidpodhola also trying to figure this out right now.
This may be of help but doesn't use the Cypress action:
https://medium.com/tomorrowapp/running-end-to-end-tests-with-github-actions-d45b70c032e6

@bahmutov
Copy link
Contributor

Similar to #152

@bahmutov bahmutov added the type: enhancement New feature or request label Nov 17, 2020
@github-actions
Copy link

🎉 This issue has been resolved in version 2.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants