Skip to content

Environment variables declared in vitest.config.ts undefined when using the extension #326

@sambarfoot

Description

@sambarfoot

Describe the bug

If env variables are defined in the vitest config files, they are undefined when using the extension

Reproduction

vitest.workspace.ts

export default [
  'packages/*'
]

vitest.config.mts

import { defineProject } from 'vitest/config'
import tsconfigPaths from 'vite-tsconfig-paths';

export default defineProject({
  plugins: [tsconfigPaths()],
  test: {
    env: {
      DATABASE_URL: "http://localhost:3000",
    }
  }
});
test('should successfully login and set access token', () => {
    // Act
    const database_url = process.env.DATABASE_URL!;
}

System Info

System:
    OS: Linux 6.6 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (10) arm64 unknown
    Memory: 4.69 GB / 7.75 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 20.12.0 - /usr/local/share/nvm/versions/node/v20.12.0/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 10.5.0 - /usr/local/share/nvm/versions/node/v20.12.0/bin/npm
    pnpm: 8.15.5 - /usr/local/share/nvm/versions/node/v20.12.0/bin/pnpm

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions