meinaart / cypress-plugin-snapshots

Plugin for snapshot tests in Cypress.io
MIT License
497 stars 117 forks source link

feat: customize` __image_snapshots__` folder path #70

Closed HOUCe closed 4 years ago

HOUCe commented 4 years ago

Hi guys, thanks for the great work of cypress-plugin-snapshots. I am currently working on implementing cypress-plugin-snapshots for my project, and I really want to customize__image_snapshots__ folder path.

Actually we use cypress during CI pipeline: as soon as the alpha(pre-release) deployment done, we will run cypress(and cypress-plugin-snapshots of course). In order to provide the snapshots' result, we have to configure __image_snapshots__ folder to a persist path in docker.

I consult the code source and supposed that making __image_snapshots__ folder path configurable is not hard and reasonable(at least by my side). Cypress also provide the ability to configure screenshotsFolder and videosFolder.

I am looking forward to your reply and ready to make a PR if it is needed.

Thanks again.

ghost commented 4 years ago

@HOUCe can you show us your workaround please?

HOUCe commented 4 years ago

@HOUCe can you show us your workaround please?

In cypress-plugin-snapshots/src/utils/image/getSnapshotFilename.js file: https://github.com/meinaart/cypress-plugin-snapshots/blob/cf07698779b40f1735cc1486cb3aa9fdcadd1f7d/src/utils/image/getSnapshotFilename.js#L6

By adding a custom path(using customAssestsPath as config variable for example) modify:

 const dir = path.join(path.dirname(testFile), DIR_IMAGE_SNAPSHOTS);

to:

const dir = customAssestsPath ? path.join(customAssestsPath, DIR_IMAGE_SNAPSHOTS)  : path.join(path.dirname(testFile), DIR_IMAGE_SNAPSHOTS);

But finally I use another plugin called cypress-image-snapshot which supports customize the assets path.

fr0 commented 4 years ago

I would like this same feature -- can this issue be re-opened?

NagaMukka commented 2 years ago

Hi Guys, I am new to cypress automation and I included snapshot plugin into my project. So, did anyone found how we can customize __image_snapshots__ folder path.