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.

Screenshot path does not corresponds to the spec path

See original GitHub issue

Current behavior

image

I have two spec files, each contains a simple test case where I take a screenshot with cy.screenshot(). Both screenshots will be saved directly under scressnshots directory.

Desired behavior

Screenshot from cypress/e2e/deep/deep-example.cy.js to be saved under cypress/screenshots/deep/deep example --passes.png

Test code to reproduce

https://github.com/odai-alali/cypress-screenshot-issue

Cypress Version

10.0.3

Other

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
shtiefcommented, Jun 22, 2022

Hello, I understand the idea to get rid of the ancestry folders. But it comes with a big disadvantage, that you can’t be sure the screenshots are in the same place. It depends on which e2e tests you are executing. You can run ALL tests but also only ONE specific test. The directory for the generated files can be different then. This is annoying, especially when you want to test with visual regression and compare snapshots. I will try the ‘after:screenshot’ solution, but I would prefer a configuration to KEEP the directory structure that is defined in the specs directory.

2reactions
marktnoonancommented, Jun 7, 2022

Hi, thanks for reporting this. I believe this is an unavoidable side effect of the change in Cypress 10 from setting an integrationFolder for specs to setting a specPattern . From the changelog for 10.0.0:

Generated screenshots and videos will still be created inside their respective folders (screenshotsFolder, videosFolder). However, the paths of generated files inside those folders will be stripped of any common ancestor paths shared between spec files found by the specPattern option and may no longer be deterministic. Addressed in #19319.

Read more comments on GitHub >

github_iconTop Results From Across the Web

File path not getting set using 'save_screenshot' for python ...
I am using python selenium to get a screenshot of test, but in ubuntu the saved screenshot is taking the path name as...
Read more >
screenshot - Cypress Documentation
Screenshots are saved inside the screenshots folder. Inside that folder, the screenshot is saved inside a folder structure relative to the path of...
Read more >
How to change your screenshot save location in Windows 10 ...
Now select the Location tab from the Screenshot Properties. You can enter the new path where you'd like your images to be saved....
Read more >
How to Add Screenshot Testing with Cypress to Your Project
The tests will pass and 5 images will be created under the /snapshots/screenshot.spec.js folder. Test Runner option. Using npm run cypress open ...
Read more >
.takeScreenshot() | TestController | Test API | API | Docs
The screenshot file's relative path and name. The path is relative to the root directory specified in the runner.screenshots API method or the...
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