Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trash assets failure with screenshots in nested folders #29404

Open
MikeMcC399 opened this issue Jul 6, 2023 · 4 comments
Open

Trash assets failure with screenshots in nested folders #29404

MikeMcC399 opened this issue Jul 6, 2023 · 4 comments

Comments

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Jul 6, 2023

If a test fails, then the option trashAssetsBeforeRuns with default true fails to delete previous screenshots on Windows 11 if there have been previous runs which produced screenshots in nested sub-folders of cypress/screenshots.

The error message is:

DevTools listening on ws://127.0.0.1:59399/devtools/browser/d422c0e5-e2d8-456e-9962-e48e167e8351
Warning: We failed to trash the existing run results.

This error will not affect or change the exit code.

Error: Command failed: C:\Users\mikem\AppData\Local\Cypress\Cache\12.13.0\Cypress\resources\app\node_modules\trash\lib\win-trash.exe C:\Users\mikem\github\cypress-io\cypress-realworld-app\cypress\screenshots\ui

    at ChildProcess.exithandler (node:child_process:407:12)
    at ChildProcess.emit (node:events:527:28)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.onexit (node:internal/child_process:302:5)

The script dev is opening the screenshots, which prevents Cypress trash from working.

Steps to reproduce

Cypress: 12.13.0 13.0.0
Operating system: Windows 11
Node.js: 16.16.0 18.16.1

Create a new test spec cypress/tests/demo/show-fail.spec.ts with the following contents which will always fail when run:

it("show test failing", function () {
  throw new Error("deliberate hard failure");
});

Execute

yarn
yarn dev

then in a separate terminal window, execute

yarn cypress:run

The new test should fail and generate 3 screenshots and 1 video.

Kill the devprocess (if necessary sign out and back in again) and repeat

yarn dev

and again in a separate terminal window, execute

yarn cypress:run

Note the error message (see above).

Attempt to delete cypress/screenshots in Windows Explorer.
Note message "Folder Access Denied / You'll need to provide administrator permission to delete this folder". Deletion is not possible.

Kill yarn dev process.

Attempt to delete cypress/screenshots in Windows Explorer.
This is successful.

Suggestions

- When RWA is reworked, consider if this can be fixed.

  • For Cypress itself, consider if the npm module trash is the best option for cleaning up temporary files (screenshots, etc.). trash readme says that the Linux implementation is not maintained. As shown by this issue it cannot delete open files. Perhaps the npm module rimraf would be a better choice for Cypress?
@MikeMcC399
Copy link
Contributor Author

@MikeMcC399
Copy link
Contributor Author

MikeMcC399 commented Jul 7, 2023

Unfortunately it seems that this issue is unreliably reproducible 🙁 although it is still happening.

When it happens, screenshot copies build up, since they can't be deleted.

@MikeMcC399
Copy link
Contributor Author

@jennifer-shehane
Copy link
Member

@MikeMcC399 It sounds like this issue should be moved to the main repo.

@jennifer-shehane jennifer-shehane transferred this issue from cypress-io/cypress-realworld-app Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants