-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 3 not working with Cypress Component Testing #22784
Comments
I tested it and the cypress was stuck on mounting in the component testing menu. Do these changes fix the issue? |
Adding the following to server: {
port: 3000,
host: '127.0.0.1'
} |
Thanks wopian, I added these configs to my |
Nice, we will make this change internally soon, so you don't need to 🎉 If someone wants to take a stab and get the glory, go for it - I can review your PR. You can look at the issue I linked in the OP telling what to do, and poke around Otherwise, I will make a PR tomorrow. |
There is an additional issue I found after getting tests up and running with Vite 3. I am using msw to mock all endpoints (in development and during testing) and i'm achieving that by basically pre-loading all the mock files I have defined as such: const req = import.meta.globEager('./**/index.js');
const modules = [];
Object.keys(req).forEach(key => {
modules.push(...req[key].default);
});
export default modules; As of Vite 3, const req = import.meta.glob('./**/index.js', {eager: true});
const modules = [];
Object.keys(req).forEach(key => {
modules.push(...req[key].default);
});
export default modules; This works great in development mode, but it fails when the mocks get loaded in Cypress. I'm not sure where the issue is, but I suspect that, because it's still using Vite < 3 under the hood somewhere, its trying to load using Is this an issue with Cypress or perhaps |
I tried updating to Vite 3.0.2 in my project, worked fine, no need for any workaround. I'm not sure why Cypress internal tests are failing, likely due to some additional layer of complexity. I'm sure it's around the localhost/port changes: https://vitejs.dev/guide/migration.html#architecture-changes-and-legacy-options Anyone else try 3.0.2 and find it works just fine? |
Yes, can confirm Vite |
Cypress fails to load and run the individual specs with Unfortunately there's no warning/error messages in the browser console or terminal as it is just a request that is never fulfilled: |
@wopian are you using React and the I'm able to do open mode with my Vue 3 + Vite 3 + Cypress 10 project, but I don't doubt there's some things we need to fix. A minimal reproduction would help. |
Vue 3. I'm travelling until Monday, but I'll see if I can put together a reproduction then 👍 |
Should be solved by this PR: #22915 |
@lmiller1990 any news on when #22915 will be merged? It's a blocker for our CI since we don't want to change all of our default I reviewed your PR and I don't see anything that looks troublesome. |
@adamdehaven I have two debug two failing tests (pipeline: https://app.circleci.com/pipelines/github/cypress-io/cypress?branch=lmiller%2Fvite-bump-v2). Once those are passing, I'll just need a few reviews. The goal is to merge this by the end of this week, so it will be released in the next Cypress version. Those are usually bi-weekly releases, so it would be within two weeks. I'm excited to have Cypress running on Vite 3 💯 |
Ok it's green! |
FWIW I solved temporarily for us by updating the config in export default defineConfig({
component: {
devServer: {
framework: 'vue',
bundler: 'vite',
viteConfig: {
server: {
host: '127.0.0.1'
}
}
},
}
}) |
I wonder if we can do something so users don't need too add React users (and others, using plugins that inject things into |
@lmiller1990 I'm not able to reproduce Here is a minimal setup where tests can only be run when you add It is the generic Vue Typescript template created by Ran with:
|
None of my projects need to set The PR I made does not address the |
It's merged and will be in the next Cypress release. |
Looks like the |
Current behavior
Vite 3 does not work.
Desired behavior
It should work.
Test code to reproduce
I created a PR with a failing test: #22748
It has some info, but there's probably more to it than the one fix suggested by the Vite team: vitejs/vite#9059. Let's track progress here.
Cypress Version
10.3.0
Other
No response
The text was updated successfully, but these errors were encountered: