You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I test a component that imports another component or file via the ~ alias, the import fails to resolve:
Error: Failed to resolve import "~/components/Counter" from "src/routes/index.tsx". Does the file exist?
Expected behavior 🤔
Ideally these imports should resolve since the dev server supports these paths.
This seems to be fixable by updating the vitest.config.ts file
import solid from 'vite-plugin-solid'
import { defineConfig } from 'vitest/config'
// new import to utilize for the alias
import path from 'path'
export default defineConfig({
plugins: [solid()],
resolve: {
conditions: ['development', 'browser'],
// define alias here
alias: {
'~': path.resolve(__dirname, './src'),
},
},
})
Steps to reproduce 🕹
Steps:
Create a new solid repo: yarn create solid. Be sure to select the vitest template
Create a new file src/routes/index.test.tsx and put in the following contents:
@agmcleod This is kinda expected behaviour, since Start will fill in the ~ alias automatically through Vinxi, whereas Vitest isn't aware of Start's configurations. Perhaps there should be @solidjs/start/vitest that fills in stuff like this, but any custom aliases would need to be duplicated in app.config.ts or vitest.config.ts unless you use a custom Vite plugin.
@Brendonovich Yeah that's what im suggesting, where the start template of vitest doesn't seem to support the aliases that start itself provides. Was able to find out the change needed to make it work, but im wondering if that can be provided by the vitest template instead?
Duplicates
Latest version
Current behavior 😯
When I test a component that imports another component or file via the ~ alias, the import fails to resolve:
Expected behavior 🤔
Ideally these imports should resolve since the dev server supports these paths.
This seems to be fixable by updating the vitest.config.ts file
Steps to reproduce 🕹
Steps:
yarn create solid
. Be sure to select the vitest templatesrc/routes/index.test.tsx
and put in the following contents:Then try to run the tests
Context 🔦
No response
Your environment 🌎
The text was updated successfully, but these errors were encountered: