Writes archives to the Cypress-managed /cypress/downloads folder instead of the project root (the /cypress/downloads folder is cleared by Cypress at the beginning of each test run). This makes sure we have correct assets and that we don't bleed assets over between test runs (e.g. if you had a spec, ran a test, then removed that spec and ran the test again, we'd expect there to not be a story entry or spec-specific assets from that removed spec).
This doesn't handle if the user has configured a custom download folder; I'll make a ticket to handle that in the future.
2 situations where /cypress/downloads folder is not cleared before a test run:
I originally planned on managing the archives directory ourselves -- clearing it out before each test run via the before:run lifecycle hook. However, this has a couple downsides:
The user would have an extra import of ours to put in their cypress.config.js file (since we shouldn't just create all lifecycle event listeners for them)
This also doesn't run in Interactive mode
I figured we might as well use the Cypress-managed directory like we do for Playwright.
How to test
Set up a Cypress project that uses Chromatic e2e
Run a spec with `npx cypress run --spec path/to/spec
Verify that the /cypress/downloads/ folder contains the chromatic-archives/ directory
Issue: #AP-3824
What Changed
Writes archives to the Cypress-managed
/cypress/downloads
folder instead of the project root (the/cypress/downloads
folder is cleared by Cypress at the beginning of each test run). This makes sure we have correct assets and that we don't bleed assets over between test runs (e.g. if you had a spec, ran a test, then removed that spec and ran the test again, we'd expect there to not be a story entry or spec-specific assets from that removed spec).This doesn't handle if the user has configured a custom download folder; I'll make a ticket to handle that in the future.
2 situations where
/cypress/downloads
folder is not cleared before a test run:npx cypress open
)trashAssetsBeforeRun
tofalse
Alternatives I considered
I originally planned on managing the archives directory ourselves -- clearing it out before each test run via the
before:run
lifecycle hook. However, this has a couple downsides:cypress.config.js
file (since we shouldn't just create all lifecycle event listeners for them)I figured we might as well use the Cypress-managed directory like we do for Playwright.
How to test
/cypress/downloads/
folder contains thechromatic-archives/
directorynpm run archive-storybook
/downloads
directorynpx cypress run --spec path/to/spec
againChange Type
maintenance
documentation
patch
minor
major