Open andrew-vdb opened 1 week ago
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 alias
with workspaces: https://stackblitz.com/~/edit/vitest-sonar-reporter-workspaces?file=packages/server/vitest.config.ts.
Hello @andrew-vdb. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction
will be closed if they have no activity within 3 days.
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 alias
specific as we simply cannot cover all possible configuration options there.
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