Skip to content

Handling .ENV files while testing #646

@peterbud

Description

@peterbud

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions