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

Vite ESM modules are not being cached across test runs #97

Open
andymerskin opened this issue May 23, 2024 · 0 comments
Open

Vite ESM modules are not being cached across test runs #97

andymerskin opened this issue May 23, 2024 · 0 comments

Comments

@andymerskin
Copy link

andymerskin commented May 23, 2024

Environment

  • cypress v13.8.1
  • cypress-vite v1.5.0
  • vite v4.5.3
  • Chrome as test browser

Description

Hey there — I'm not sure if this is specifically caused by the cypress-vite plugin, but I'm not really sure where to start tracking this issue down.

We recently upgraded from Cypress 10 to 13 with no changes needed to our configuration or plugins. Since then, on every test run using cypress open in Chrome, every module for our app is being fetched as if it hadn't been cached, giving us 200 response codes for all of them. This is making test runs extremely slow during local development.

This is behaving as if "Disable cache" were checked in the Network tab of DevTools, where Vite would serve each module fresh every time, however I have "Disable cache" turned off in DevTools within Cypress's Chrome instance. Running a test, and then clicking the "Run all tests" button again to re-run them, none of the modules are cached.

Is this an issue with cypress-vite potentially, or in my Cypress configuration perhaps? I didn't see anything specific to request/module behavior in their migration guides, but maybe I overlooked something.

Undesired Behaviors

  1. Vite ESM modules are always coming back with status 200, not being cached in Cypress's browser (is this normal so cy.intercept can inspect them?)
  2. Every single Vite module fetch appears in the Test Log, flooding it to a point where it becomes unusable.
  3. After hiding all fetch and XHR requests in the test log using a global cy.intercept, tests are still intermittently failing due to Vite modules not fetching + loading in time

Expected Behavior

  1. Vite ESM modules should cache after the first request, with status 304 on subsequent requests when re-running tests, etc.
  2. Fetch requests for Vite ESM modules are suppressed in the Test Log
  3. Vite modules load quickly enough for tests to execute, or wait for tests to execute after cy.visit is called, until all known ES modules have loaded upfront

Any help would be greatly appreciated, and if this doesn't seem like it's within the scope of cypress-vite's issues, I will bug the Cypress team as well. So far I haven't found any relevant GitHub issues or StackOverflow posts with any similar issues.

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

No branches or pull requests

1 participant