cypress-image-snapshot icon indicating copy to clipboard operation
cypress-image-snapshot copied to clipboard

--env customSnapshotsDir ?

Open nodje opened this issue 4 years ago • 3 comments

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

nodje avatar Mar 25 '20 08:03 nodje

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.

christophamma avatar Mar 25 '20 10:03 christophamma

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.

nodje avatar Mar 25 '20 13:03 nodje

@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.

ivanbtrujillo avatar Mar 25 '21 09:03 ivanbtrujillo