-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
How to use alias with vitest workspace #6503
Comments
You could try something like: import { defineWorkspace } from 'vitest/config'
import { resolve } from 'path';
export default defineWorkspace(
[
{
test: {
include: ['./packageName/**/*.spec.{ts,js}'],
name: 'packageName',
alias: {
- '@': resolve(__dirname, './'),
+ '@': resolve(__dirname, './packageName'),
}
}
}
]) But without seeing rest of your project's code it's impossible to help any further. Here's also one example that uses |
Hello @andrew-vdb. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with |
The proposed solution is already working, sorry that i may not be clear enough. The issue is when i googled and reading the doc, no one mention to put alias in defineWorkspace |
Doesn't https://vitest.dev/guide/workspace already cover configuring workspaces? What kind of change would you propose there? It shouldn't be |
it can be faq or troubleshoot when following conditions are true
Please add alias in vitest.workspace.ts worse case they can also find this issue |
Clear and concise description of the problem
No documentation.
intellisense is working in my spec file no import error but vitest extension for some reason can not load module with alias
Suggested solution
When using workspace, put the resolve in the "vitest.workspace.ts" !
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: