Cypress: Proposal: Nest screenshot path based on spec path by default

Created on 30 May 2018  路  5Comments  路  Source: cypress-io/cypress

Instead of saving screenshots all directly in the screenshots directory, nest them based on where the spec file is relative to the integration directory. So if running

cypress/integration/app/login/user_spec.js

a screenshot will be saved as

cypress/screenshots/app/login/user_spec.js -- login -- users -- can log in.png.

pkserver enhancement

Most helpful comment

Definitely don't take into account the unit vs integration stuff.

It is a good point, but I don't think we can factor that in right now.

All 5 comments

@brian-mann What about when/if we eventually support having different folders for unit and e2e tests? Should we include the test type too to avoid collisions?

So the pattern is:

{screenshotsFolder}/{type}/{specPath}{testName}.png

with

cypress/integration/app/login/user_spec.js

saved as

cypress/screenshots/integration/app/login/user_spec.js -- login -- users -- can log in.png

Definitely don't take into account the unit vs integration stuff.

It is a good point, but I don't think we can factor that in right now.

Released in 3.0.2.

Well, this is quite a breaking change for a minor release. :/
Could you please at least update the documentation to match this behaviour?
https://docs.cypress.io/api/commands/screenshot.html does not reflect this yet.

@phryneas Sorry for the inconvenience. There has been a new section added to the screenshots docs on "Naming conventions", hopefully this helps.

Was this page helpful?
0 / 5 - 0 ratings