mammadataei / cypress-vite

Run Cypress specs using Vite
MIT License
85 stars 10 forks source link

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

Open andymerskin opened 3 months ago

andymerskin commented 3 months ago

Environment

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.