'Bitbucket Pipelines hangs when testing a Nuxt app with Cypress

I have a Nuxt app that I want to test with Cypress in CI. I've seen in the Cypress documentation that you have to install some third-party package to wait for the server to start and then run your tests. I then installed the wait-on package and created these scripts in package.json.

package.json

"scripts": {
  "start:wait": "yarn start & wait-on http://localhost:3000",
  "run:cypress": "cypress run"  
},

For the CI, I install the dependencies, run nuxt generate to bundle the app and then test using the step below.

bitbucket-pipelines.yml

- step: &e2e-test
    image: cypress/included:9.4.1
    name: Run application E2E tests
    caches:
      - cypress
    script:
      - yarn start:wait
      - yarn record:cypress -- --config video=true --parallel --ci-build-id $BITBUCKET_BUILD_NUMBER
    artifacts:
      # store any generates images and videos as artifacts
      - cypress/screenshots/**
      - cypress/videos/**

# A little bit below
- parallel:
    - step: *e2e-test
    - step: *e2e-test
    - step: *e2e-test

It works when I test it locally but in CI, Bitbucket hangs and nothing happens.

enter image description here

I've also seen the start-server-and-test package but I don't know how to pass extra arguments like (--config video=true --parallel --ci-build-id $BITBUCKET_BUILD_NUMBER) to run:cypress from the CI.

"ci": "start-server-and-test 'yarn start' http://localhost:3000 'run-cypress <extra-arguments-here?>'"

Like this but with arguments from the CI to retrieve $BITBUCKET_BUILD_NUMBER



Solution 1:[1]

follow these examples: official cypress doc

bitbucket yml example for Cypress

I suppose you didn't provide in the script

yarn install 

or

yarn install --frozen-lockfile

and main script

yarn start-server-and-test start [<http://localhost:3000>](<http://localhost:2020/>) cypress run --record --key PRODUCT_KEY --parallel --ci-build-id $BITBUCKET_BUILD_NUMBER

Where PRODUCT_KEY is your key from Cypress Dashboard. and Rewrite parallel part as in the example above.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Andronicus