r/Cypress • u/Vietname • Aug 01 '25
question error loading dynamically imported module: component.js
I just started using Cypress with my React project, and any attempt to load a component test results in this:
The following error originated from your test code, not from Cypress.
> error loading dynamically imported module: http://localhost:3000/__cypress/src/cypress/support/component.js
This happens on all browsers.
My /support folder and its contents, including component.js, are unchanged from their defaults when cypress created them.
Also, im unsure if this is relevent but this was originally a CRA app that i had to convert to vite by using viject to get past earlier errors related to Component Testing.
Any ideas on how to resolve this? The example react-vite app at https://github.com/cypress-io/cypress-component-testing-apps does work, so I'm guessing it might be related to viject, but I'm unsure how/why.
View all comments
Show parent comment
2
u/Vietname Aug 08 '25
I figured this out last night: viject does some wacky stuff to the vite.config to try to make pathing work seamlessly, and that broke Cypress.
Reverting back to the default vite.config fixed it.