0

Cypress has been running great locally. When I try running it in the circle-ci pipeline then it has a number of issues. First, here is the relevant part of my workflow:

orbs:
  cypress: cypress-io/cypress@1.19.2
workflows:
  version: 2.1
  commit:
    jobs:
      - cypress/install:
          install-command: 'npm install --no-optional --unsafe-perm'

      - cypress/run:
          requires:
            - cypress/install
          start: 'lerna run start --parallel'

When I view the operations in circle-ci, it successfully compiled but immediately cancels

project/applicable-folder: ℹ 「wdm」: Compiled successfully.


Build was canceled

and in the build process I notice this line

project/applicable-folder: Failed to load /root/project/.env.

The .env is absolutely there.

npx cypress run does run after this but all of the tests fail since even the test for cy.visit('/'); fails.

Why is the env file not successfully accessed? Am I missing a step that allows for this to run? Am I even supposed to allow it to run? I am uncertain about how to proceed.

I have also tried to use the build instead of start but this does not work any better.

I have also used a manual strategy:

test:e2e: docker: - image: docker-image steps: - checkout - restore_cache: keys: - v2-deps-{{ .Branch }}-{{ checksum "package-lock.json" }} - v2-deps-{{ .Branch }}- - v2-deps- - run: npm ci - save_cache: key: v2-deps-{{ .Branch }}-{{ checksum "package-lock.json" }} paths: - ~/.npm - ~/.cache - run: name: Run user acceptance tests command: npm run cy:run

This will result in a requirement for Xvfb to be installed.

Will this mean that it should work provided that that is installed? I would rather have the orb version work.

EDIT: I tried out the library start-server-and-test.

scripts are as follows

"cy:pipeline": "start-server-and-test up http-get://localhost:8080 cy:run"
"cy:run": "cypress run --headless --record"
"up": "lerna run start --parallel"

The new cypress/run

  - cypress/run:
      requires:
        - cypress/install
      record: true
      command: 'npm run cy:pipeline'

But I have been receiving the same errors,

Brandon
  • 1,447
  • 2
  • 21
  • 41

3 Answers3

1

The solution was simple.

All I had to do was move the install-command from cypress/install to cypress/run.

  - cypress/install

  - cypress/run:
      requires:
        - cypress/install
      start: 'lerna run start --parallel'
      install-command: 'npm install --no-optional --unsafe-perm'
Brandon
  • 1,447
  • 2
  • 21
  • 41
0

Try to watch this great presentation from official circleci youtube channel on cypress integration, it should be helpful to resolve your question

Alexander Tunick
  • 517
  • 1
  • 6
  • 20
  • I have watched that video and it is very informative. As far as I can tell, what I have setup should work. – Brandon Apr 22 '20 at 14:10
0

I think the webpack dev server is exiting immediately, is this react-scripts by any chance?

gleb bahmutov
  • 1,801
  • 15
  • 10
  • What is causing it to exit immediately? It is not using react-scripts. – Brandon Apr 22 '20 at 16:28
  • I edited the question to include a `start-server-and-test` attempt. It tried to run the tests but failed to load `/` even though the plugin has an inherent wait built in. Which means that the plugin found :8080 but cypress didn't? – Brandon Apr 22 '20 at 17:16