Skip to content

fix(vite): vitest skipping nuxt imports transformations #3925

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

Merged
merged 2 commits into from
Apr 18, 2025

Conversation

fm96-dev
Copy link
Contributor

πŸ”— Linked issue

Resolves #3213

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

In my case, the issue was with #build/app.config, but it also impacts #imports and other Nuxt-related imports.
To fix this, augment the Vite configuration within the AppConfigPlugin for Vite/Vue projects.
This involves adding the @nuxt/ui dependency to the test.server.deps.inline option.

This step is necessary because Vitest skips transforming files inside the node_modules folder by default.
While the AppConfigPlugin itself was functioning correctly, the load hook wasn't being appliedβ€”preventing Vitest from loading the virtual module properly

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

…line` to handle virtual imports in vitest tests
Copy link

pkg-pr-new bot commented Apr 17, 2025

npm i https://pkg.pr.new/@nuxt/ui@3925

commit: f838435

@benjamincanac benjamincanac requested a review from danielroe April 17, 2025 19:13
@benjamincanac benjamincanac changed the title fix: vitest skipping nuxt imports transformations when using vue fix(vite): vitest skipping nuxt imports transformations Apr 18, 2025
Copy link
Member

@benjamincanac benjamincanac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 😊

@benjamincanac benjamincanac merged commit c31bffa into nuxt:v3 Apr 18, 2025
5 checks passed
@benjamincanac benjamincanac added the v3 #1289 label Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 #1289
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError when Setting Up Vitest
3 participants