Skip to content
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

Handling .ENV files while testing #646

Closed
peterbud opened this issue Dec 13, 2023 · 0 comments · Fixed by #655
Closed

Handling .ENV files while testing #646

peterbud opened this issue Dec 13, 2023 · 0 comments · Fixed by #655
Assignees
Labels
enhancement New feature or request vitest-environment

Comments

@peterbud
Copy link

Environment

Working directory: /home/projects/nuxt-vitest-pvfdx1 3:18:25 PM
Nuxt project info: 3:18:25 PM


  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.8.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: [email protected]
  • Builder: -
  • User Config: modules, devtools, runtimeConfig
  • Runtime Modules: -
  • Build Modules: -

Reproduction

See repo:
https://stackblitz.com/edit/nuxt-vitest-pvfdx1

Running pnpm dev shows that runtimeconfig public.hello is initialized by the .ENV file
Running pnpm test shows that runtimeconfig public.hello is empty

Describe the bug

When running pnpm dev the .ENV file's content is being applied, and calling useRuntimeConfig() results values which are initialized based on the content of the .ENV file

However when running vitest, .ENV file is not applied, and runtimeconfig values are not initialized with it.

What is the designated way to influence the environment variables while running tests?

Additional context

No response

Logs

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vitest-environment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants