Vitest - import with alias not working

It seems that after the release that support vitest, my aliased import files are not recognized anymore in my spec files only.

I have 2 different config files (which are basically almost the same):
- vite.config.ts and vitest.config.ts

In my configuration i set my vitest config file path, however it didn't solve the issue:

In my spec files aliased import are not working:

However outside my test file it works:

 

5 comments
Comment actions Permalink

Does it work if you use non-aliased path? I believe that the actual issue is that the IDE doesn't expect .vue files imports in .ts files and resolves import to d.ts shim where the corresponding module is declared

0
Comment actions Permalink

Yes it works if i don't use the alias import.

0
Comment actions Permalink

Weird. Actually it works for me when using both aliased and non-aliased imports, so it must be a configuration issue. Do you have a sample project you could share that reproduces the problem?

0
Comment actions Permalink

I fixed by updating my tsconfig.json file.

It was missing in the include property the tests folder: 

"include": [
"src/**/*.ts",
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts" <--- this line was missing
]
1
Comment actions Permalink

Fine, thanks for letting me know!

0

Please sign in to leave a comment.