Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put Cypress archives in temp directory #38

Merged
merged 4 commits into from
Nov 20, 2023

Conversation

skitterm
Copy link
Member

@skitterm skitterm commented Nov 17, 2023

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:

  1. Cypress in interactive mode (e.g. npx cypress open)
  2. User configures trashAssetsBeforeRun to false

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:

  1. 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)
  2. 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

  1. Set up a Cypress project that uses Chromatic e2e
  2. Run a spec with `npx cypress run --spec path/to/spec
  3. Verify that the /cypress/downloads/ folder contains the chromatic-archives/ directory
  4. Run npm run archive-storybook
  5. Verify that the story has the correct assets
  6. Add some random file to the /downloads directory
  7. Run npx cypress run --spec path/to/spec again
  8. Verify that the random file is blown away

Change Type

  • maintenance
  • documentation
  • patch
  • minor
  • major

@skitterm skitterm requested a review from tevanoff November 17, 2023 23:20
// TODO: change so we don't have to do this trickery
outputDir: './some',
outputDir: './cypress/downloads/some',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's weird with this /some directory business in there (needed because we go back a directory in writeTestResult), but I'd like to tackle that later when we reuse code between Playwright and Cypress.

Copy link
Contributor

@tevanoff tevanoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@skitterm skitterm merged commit a34f1fa into main Nov 20, 2023
2 checks passed
@thafryer
Copy link
Member

🚀 PR was released in v0.0.40 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants