-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Vitest workspace run doesn't pick .env from individual projects #5448
Copy link
Copy link
Closed
Labels
feat: workspaceIssues and PRs related to the workspace featureIssues and PRs related to the workspace featurep3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)
Description
Describe the bug
I have a monorepo with different projects in packages/*, when we run vitest inside of this packages the .env.{mode} it's picked correctly, but when running in the root of the monorepo, 0 variables are caught.
We have a vitest.workspace.mts file in the root with the following:
export default ["packages/*", "apps/*"];We define the vitest.config.ts in the packages/ like this:
import tsconfigPaths from "vite-tsconfig-paths";
import { defineProject } from "vitest/config";
export default defineProject({
envPrefix: ["SHERPAS_", "DATABASE_", "FLY_", "PRIMARY_"],
plugins: [
tsconfigPaths({
root: "../..",
}),
],
test: {
hookTimeout: 20_000,
exclude: [
"node_modules",
"dist",
".idea",
".git",
".cache",
"src/tests/**/*.{ts,tsx}",
],
environment: "jsdom",
},
});Initially created as discussion here: #5446
Reproduction
stackblitz.com/edit/vitest-dev-vitest-pxuer9?file=packages%2Flib1%2F.env.test
System Info
System:
OS: macOS 14.0
CPU: (10) arm64 Apple M2 Pro
Memory: 72.27 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.11.1 - ~/Library/Caches/fnm_multishells/70491_1711450154965/bin/node
npm: 10.2.4 - ~/Library/Caches/fnm_multishells/70491_1711450154965/bin/npm
pnpm: 8.15.5 - ~/Library/pnpm/pnpm
bun: 1.0.0 - ~/.bun/bin/bun
Browsers:
Chrome: 123.0.6312.86
Safari: 17.0
npmPackages:
vitest: ^1.4.0 => 1.4.0Used Package Manager
pnpm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feat: workspaceIssues and PRs related to the workspace featureIssues and PRs related to the workspace featurep3-minor-bugAn edge case that only affects very specific usage (priority)An edge case that only affects very specific usage (priority)