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,
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'