Goal: I want to be able to store my Cypress test results so I can start using the re-run failed tests option in CircleCI.
Problem. On the “Uploading Test Results” step of my Cypress tests, I get the following error
Unable to save test results from /root/project/cypress
Error error accessing path "/root/project/cypress": stat /root/project/cypress: no such file or directory
Found no test results, skipping
I’m using the orb cypress-io/cypress@2.2.0 to run Cypress.
Here’s the relevant code from my circleci config:
could it be saving them in /root/project/frontend/cypress?
also did you add the cypress-circleci-reporter to your package.json? I think that reporter will save things in a test_results directory by default? cypress-circleci-reporter - npm
it won’t show up in the tests tab unless the store_test_results step that you put in your first message has a successful upload.
so that’s why i’m wondering if maybe cypress is storing them in a test_results directory and then if you change store_test_results to look at test_results instead of the cypress path, maybe they are there?
A simple question - what is your executor cypress-18-16-1 defined as?
Without knowing what environment you have defined I can not give a clear answer, but in most environments, the job would not be running as the root user and so would not have access to the root directory.
The easy way to check would be to just place the following into the script
pwd
whoami
echo hi > /root/testfile
As that would provide the current working directory, the account that is being used to run the job and a basic check to see if you can write into the root directory.
The next question I have to ask is why are you using such a dated version of the cypress ORB? 2.2.0 is from Sept 2022, while you are defining a very recent version of Node to be the executor environment.
As Sebastian noted in one of his replies this seems to be an issue with directories. If the working directory is set as /root/project/frontend the cypress directory should end up as /root/project/frontend/cypress
Beyond those comments/ideas you may want to see what level of support the cypress team can give users of the ORB as it is their code base rather than CircleCI’s. They have a community chat on Discord at https://discord.gg/cypress
We are on version 2.2.0 because the migration process to version 3.3.0 was not straightforward, and that we also use version 12 of Cypress, which was the latest major version at the time we set up our tests. There is a /root/project/frontend/cypress directory, it where the videos from the tests are saved. When it comes to storing test results, I just doesnt work.
I think you may be able to get more support from the Cypress discord forum as there should be a wider range of active users there.
With the answers you have provided, the issue does seem to be within the configuration of the Cypress ORB rather than the CircleCI environment, but without decoding the source code of the ORB it is hard to tell exactly what is going wrong.
i’m trying to pinpoint if it’s the reporter that’s the issue or the cypress invokation. i’m also wondering if the old cypress orb might be an issue as well…
Hi! Sorry for the delay, I’m picking this back up from @lritter79. We did decide to upgrade the Cypress orb after all, since you’re right, the version we were using was quite old. Now we are on version 3.3.0, and our tests are running again. I do get a permissions error now during the “Restore Cypress cache” step that looks like this (but ca 25k lines):
Unable to set permissions on "/root/.cache/Cypress/12.17.4/Cypress/resources/[...]" - chmod /root/.cache/Cypress/12.17.4/Cypress/resources/app/[...]: permission denied
And now, after the upgrade, the pwd / whoami / echo hi > /root/file command give the following output:
/home/circleci/project/frontend
circleci
/bin/bash: line 3: /root/file: Permission denied
So now the job is run under the circleci user (before it was root). Is there a way for us to give the circleci user the permissions it needs?
The Cypress ORB allows you to set your own cache-path
The original posted script also contained
working_directory: /root/project/frontend
So you may have other code that needs to be changed so that you are not dependent on the root account.
If you use the default environment defined by the ORB you can not use the root account as it defines a docker based environment. You could override this to use a machine environment, but it would be best to ask in the Cypress forums as they are the ones who know the code.