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

feat!: read .env.test + allow overriding with nuxt.dotenv #655

Merged
merged 5 commits into from
Dec 18, 2023
Merged

Conversation

danielroe
Copy link
Member

resolves #646

This PR now reads in .env.test when running vitest and allows the user to configure this with environmentOptions.nuxt.dotenv. (It's also possible to pass key/value pairs of environment rather than use .env.test, for example.)

This currently uses a clone of the Nitro logic from https://github.com/unjs/nitro/tree/main/src/runtime/utils.env.ts but it would be nice to avoid duplication by using a normalised nuxt.options.runtimeConfig in place (when nuxt/nuxt#24224 merges) which ideally would also involve exporting the utility from nitro (cc: @pi0).

Note: This also changes the public API of getVitestConfigFromNuxt which is currently only being used (as far as I can tell) by @wattanx in https://github.com/wattanx/nuxt-bridge-vitest - which is, anyway, a clone rather than direct usage.

@danielroe danielroe requested a review from antfu December 16, 2023 22:43
@danielroe danielroe changed the title feat!: read .env.test and allow overriding with nuxt.dotenv options feat!: read .env.test + allow overriding with nuxt.dotenv Dec 18, 2023
@danielroe danielroe merged commit 8cf01bd into main Dec 18, 2023
3 checks passed
@danielroe danielroe deleted the feat/env branch December 18, 2023 14:40
kier-mc added a commit to kier-mc/task-hub that referenced this pull request Feb 16, 2024
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 this pull request may close these issues.

Handling .ENV files while testing
2 participants