question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cypress deletes screenshotsFolder and videosFolder, loosing their original permissions

See original GitHub issue

Current behavior:

When Cypress is launched using cypress run with the trashAssetsBeforeRuns=true, it will delete (move to trash, to be more precise) the whole screenshotsFolder and videosFolder. After re-creating them, they’ll have different access control settings (file system-wise) then originally.

See “Steps to reproduce” for details and why it’s an issue.

I realize it’s an exotic issue, and I can work around it fairly easily without fixing Cypress. So feel free to close if you don’t consider this to be a bug.

Desired behavior:

Cypress deletes the contents of screenshotsFolder and videosFolder directories, but not the directories themselves. Thus, it preserves their filesystem owner settings, and rwx settings.

Cypress has an option to permanently delete those files, not only move them to trash (to avoid similar issue with the .Trash directory itself)

Steps to reproduce:

  1. CI agent is deleting /artifacts directory.
  2. CI agent is recreating this directory, as a non-privileged users, so that it looks like:
artifacts/
    - screenshots/
    - videos/
  1. Cypress, running in a Docker container, is executing a test as a root user. It has access to the /results folder because it’s mounted as a Docker volume. It deletes screenshots/ and videos/ and re-creates them.

  2. Test passes.

  3. Next test is about to run on the very same agent. Agent fails to delete /results/videos/lorem.mp4 - it has no write access to videos/ and screenshots/, because they were created as root.

Versions

Running in Docker, on Linux. Custom setup, not based on Cypress’ docker images.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
lilaconleecommented, Nov 14, 2018

Hey @kamituel, some more issues popped up with trashing so we opted to permanently delete the contents of directories in Linux as you mentioned. This was done in #2745 and will be released with 3.1.2

1reaction
CGastrellcommented, Aug 6, 2018

Hi everyone, I stumbled upon some very similar scenario and I was wondering: why trash the complete directory? Why not rm -rf {videosFolder}/* (idem for screenshots).

I know it’s safer/cleaner to rm the whole dir but that way also messes with .gitignore strategies.

To be specific: I want to keep the folders (videos & screenshots) so I don’t have to worry about not existing/permissions/etc. So I keep a .gitignore inside those dirs, but as the trashing gets rid of the whole dir, my strategy also gets trashed.

I think I’m suggesting the same as @brian-mann which, in the end, points to not messing with directory structure of the project

Besides personal or coding strategies, I think trashing the folders will continue to raise problems on different scenarios.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Screenshots and Videos - Cypress Documentation
Screenshots are stored in the screenshotsFolder which is set to cypress/screenshots by default. Cypress clears any existing screenshots before cypress run .
Read more >
cypress-io/cypress - Gitter
Hey! I was trying to implement testing with Cypress in our app, but there is an error that stopping me. describe("Login", function() ...
Read more >
Controlling Browser Permissions in Cypress End-to-End Tests
It helps control the permission level of various browser features such as: Desktop Notifications; Geolocation; Images; Camera; Microphone; etc.
Read more >
How to delete all screenshots before a test run while doing a ...
... the option "trashAssetsBeforeRuns": true in cypress.json file, which will delete the screenshotsFolder and videosFolder before each test ...
Read more >
cypress: Versions - Openbase
Upgraded the Chromium browser version used during cypress run and when selecting Electron browser in cypress open from 94.0.4606.81 to 100.0.4896.75 . Addressed ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found