jaredpalmer / cypress-image-snapshot

Catch visual regressions in Cypress
MIT License
888 stars 160 forks source link

--env customSnapshotsDir ? #126

Open nodje opened 4 years ago

nodje commented 4 years ago

It'd be highly convenient to have a way to pass customSnapshotsDir value from the CLI!

christophamma commented 4 years ago

I just came across this yesterday and solved it that way:

cypress run --env customSnapshotsDir=cypress/snapshots/CI

and then in command.js set it globally via:

addMatchImageSnapshotCommand({ customSnapshotsDir: Cypress.env('customSnapshotsDir') }); However this took me a while to find out since I thought setting it via --env would be enough, so I agree, that this should be able to pass via CLI without doing changes in code.

nodje commented 4 years ago

This cypress run --env customSnapshotsDir=cypress/snapshots/CI doesn't work, that's my point. You need to set it up globally in command.js, which is not convenient.

It should be possible to override this setting from CLI.

ivanbtrujillo commented 3 years ago

@nodje Instead of:

cypress run --env customSnapshotsDir=cypress/snapshots/CI

Use:

CYPRESS_customSnapshotsDir=cypress/snapshots/CI

And what @christophamma mentioned: addMatchImageSnapshotCommand({ customSnapshotsDir: Cypress.env('customSnapshotsDir') });

It works for me.