-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Vitest cannot resolve imports using aliases #17685
Comments
did you setup the same aliases in the vitest as well? |
@Smrtnyk I tried for some, it worked for them, however I thought the vitest config will get that information from the generated |
Why copying and not just extending the same file (.quasar/tsconfig.json)? |
@rstoenescu I am confused. How can I extend the |
Related issues:
Workaround: // create a file called /app-vite-testing-shim.d.ts
declare module '@quasar/app-vite/lib/testing.js' {
import { type UserConfig } from 'vite'
export function getTestingConfig(ctxParams?: Record<string, unknown>): Promise<UserConfig>
} import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import { quasar, transformAssetUrls } from '@quasar/vite-plugin'
import { getTestingConfig } from '@quasar/app-vite/lib/testing.js'
// https://vitejs.dev/config/
export default defineConfig(async () => ({
resolve: {
alias: (await getTestingConfig()).resolve.alias,
},
test: {
environment: 'happy-dom',
setupFiles: 'test/vitest/setup-file.ts',
include: [
// Matches vitest tests in any subfolder of 'src' or into 'test/vitest/__tests__'
// Matches all files with extension 'js', 'jsx', 'ts' and 'tsx'
'src/**/*.vitest.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
'test/vitest/__tests__/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
],
},
plugins: [
vue({
template: { transformAssetUrls },
}),
quasar({
sassVariables: 'src/quasar-variables.scss',
}),
],
})) |
I investigated this yesterday. Now, the problem should be gone with But, we will also consider improving the |
Also, next time, please use https://github.com/quasarframework/quasar-testing/issues for testing-related issues, thanks. |
That means we should improve the |
What happened?
Hello,
yesterday I set up a completly new and empty quasar project with app-vite 2.0. After that I added testing (vitest) via
quasar ext add @quasar/testing-unit-vitest
as mentioned in the documentation. However, as soon as I import something from my source folder, I get this error message running the tests.It seems like a problem with the folder aliases that cannot be resolved using vitest.
I hope there is an easy/quick solution. :)
Best regards and thanks for you work!
Julian
What did you expect to happen?
The imports should be resolved.
Reproduction URL
https://stackblitz.com/edit/stackblitz-starters-khocqz
How to reproduce?
Flavour
Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)
Areas
Project Creation (create-quasar)
Platforms/Browsers
No response
Quasar info output
No response
Relevant log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: