cypress-vite
cypress-vite copied to clipboard
Vite ESM modules are not being cached across test runs
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
- 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?) - Every single Vite module fetch appears in the Test Log, flooding it to a point where it becomes unusable.
- After hiding all
fetch
and XHR requests in the test log using a globalcy.intercept
, tests are still intermittently failing due to Vite modules not fetching + loading in time
Expected Behavior
- Vite ESM modules should cache after the first request, with status 304 on subsequent requests when re-running tests, etc.
- Fetch requests for Vite ESM modules are suppressed in the Test Log
- 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.