cypress: Component testing with Vite is failing due to the outdated bundled `graceful-fs` version

Current behavior

Component testing with Vite in new projects doesn’t work. There will be errors like:

[vite] Internal server error: Cannot read properties of undefined (reading 'uid') Failed to fetch dynamically imported module: http://localhost:3001/src/components/__tests__/HelloWorld.spec.js?import

The direct cause is the latest version of resolve. It exposes a bug in older versions of graceful-fs. Because Cypress bundles graceful-fs by itself, there seems no way for users to fix it by themselves.

More technical details is explained at https://github.com/browserify/resolve/issues/264#issuecomment-1006948040

Desired behavior

Update the bundled graceful-fs version to >= 4.2.9

Test code to reproduce

https://github.com/robyedlin/vue3-starter

Cypress Version

9.2.0

Other

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 5
  • Comments: 16 (4 by maintainers)

Most upvoted comments

@ljharb the issue has nothing to do with svelte.

In my case it is getting thrown from the Cypress app bundle. Cypress app bundles graceful-fs from where this error is thrown. Here’s the error snippet that shows the source of the error.

Opening Cypress...
 > ../../../../../Library/Caches/Cypress/9.2.1/Cypress.app/Contents/Resources/app/packages/server/node_modules/graceful-fs/polyfills.js:303:16: error: [plugin: vite:dep-scan] Cannot read properties of undefined (reading 'uid')
    303 │       if (stats.uid < 0) stats.uid += 0x100000000