Marc Pont
Marc Pont

Reputation: 1078

Quasar CLI project with cypress e2e not working on github actions

I'm working with a Quasar CLI with vite project. I installed the testing extension with cypress e2e and do some tests and on my computer are passing.

My env is: Macos 12. Node 16.

Then I tried to implement a CI with github actions, and this is the code:

ci.yml

jobs:
  ci:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Setup node env
        uses: actions/[email protected]
        with:
          node-version: 16
          check-latest: true

      - name: Install dependencies
        run: npm ci --prefer-offline --no-audit

      - name: Run e2e tests
        run: npm run test:e2e:ci

It fails the test showing this error:

Failed to fetch dynamically imported module: http://localhost:9000/src/boot/axios.js

How can give that error? This file exists. In my computer the tests are passing, the app is working fine... I don't know what to do... the code is the same, how can work on mine and fail on github actions?

How can I debug this problem?

EDIT: I was trying to change the runs-on prop but it fails with macos-latest too... so I don't understand what is going on.

Thank you

Upvotes: 1

Views: 433

Answers (1)

Marc Pont
Marc Pont

Reputation: 1078

I don't figure out why exactly produces this error, but I could solve the problem.

Reading cypress documentation I found this section:

https://docs.cypress.io/api/events/catalog-of-events#Uncaught-Exceptions

So cypress fails the tests when an exception is fired.

Just for trying things I did what docs suggest to avoid failing tests when an exception is fired:

Adding this code in: /test/cypress/support/index.js

Cypress.on('uncaught:exception', () => {
  // returning false here prevents Cypress from
  // failing the test
  return false
})

And tests are passed :D

What worries me is doing that I'm ignoring all the exceptions, but in the same time, if my app is firing exceptions probably it's not going to work fine so it will fail the tests anyway.

Talking with Quasar core members, seems that Vite does a couple of reloads while compiling, so probably this is the problem.

On the first load the file src/boot/axios.js does not exist and fires the exception, and cypress stops the runner. Adding the snippet cypress waits for the application to run, doing a couple of reloads, the thing is, when the app is ready the axios file exists.

If someone has a better solution I would like to hear it :)

Upvotes: 1

Related Questions