-
Notifications
You must be signed in to change notification settings - Fork 90
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
Override runtimeConfig
in vitest.config.ts
file doesn't seem to work
#833
Comments
To address the issue of overriding
import { defineVitestConfig } from '@nuxt/test-utils/config';
export default defineVitestConfig({
test: {
environment: 'nuxt',
globals: true,
environmentOptions: {
nuxt: {
overrides: {
runtimeConfig: {
publicRuntimeConfig: {
databaseUrl: 'your_in-memory_database_connection_string',
},
},
},
},
},
},
});
export default defineVitestConfig({
test: {
environmentOptions: {
nuxt: {
dotenv: {
fileName: '.env.test',
},
overrides: {
// Your overrides here
},
},
},
},
});
By ensuring your
|
Sorry for writing on this issue @ricardogobbosouza I have an error where the test utils not getting my custom env vars. I tried overrwriting using the I created an plugin for my api like mentioned here https://nuxt.com/docs/guide/recipes/custom-usefetch setting the baseURL as follows const config: RuntimeConfig = useRuntimeConfig();
const api = $fetch.create({
baseURL: config.public.apiBase, So my tests are always trying to run against the |
The You can track #531 for server environment support, if you're looking for a vitest runtime environment. Alternatively, you can override runtimeConfig when running your e2e setup by passing it as an override to the Note that I couldn't see any example of the kind of test you're trying to do in your linked reproduction. |
Environment
Reproduction
https://github.com/vctrtvfrrr/hinario-reformado
Describe the bug
I can't test the Nuxt3 server endpoints. I'm using
vitest
and@nuxt/test-utils
to make API calls, but I haven't even been able to override the Nuxt runtime settings:Nuxt's official documentation doesn't cover server testing very well and Nitro/H3 doesn't even have testing documentation.
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: