Closed Oli8 closed 4 months ago
Looks like the error is expected since you import db
directly instead of using setup/$fetch
from Nuxt: https://nuxt.com/docs/getting-started/testing#setup-1
Your configuration is set up by Nuxt config, Vitest just runs the code as it was told. From a quick glance, you are relying on experimental decorators. Vitest uses esbuild to process TS files, you can configure it manually via esbuild
option:
import { defineVitestConfig } from '@nuxt/test-utils/config'
export default defineVitestConfig({
esbuild: {
tsconfigRaw: {
compilerOptions: {
experimentalDecorators: true,
},
},
},
test: { globals: true },
})
Describe the bug
I'm experiencing issues with decorators when running tests using Vitest in a Nuxt 3 project.
The decorators work fine in the rest of the application, but when I run the tests, I encounter errors indicating that decorators are not valid.
When running npm test, I receive the following errors:
Reproduction
https://github.com/Oli8/repr-vitest-nuxt-decorator-error
System Info
Used Package Manager
npm
Validations