I want to use aliases in tests files with vitest
:
import { describe, expect, it } from 'vitest'
import Plan from '@/modules/Pricing/models/Plan'
let plan: Plan
describe('Plan model', () => {
it('should bind properties correctly', () => {
plan = new Plan({ id: 1234, name: 'columbo', price: 999 })
expect(plan).toEqual({ id: 1234, name: 'columbo', price: 999 })
})
})
It's a Nuxt app, I tried to configure the alias in nuxt.config.ts
:
export default defineNuxtConfig({
ssr: true,
vite: {
resolve: {
alias: [
{ find: '@', replacement: path.resolve(__dirname, '.') }
]
}
},
// ...
})
When I start the test, I got this error: