Vitest · Method
vi.stubEnv
vi.stubEnv temporarily changes an environment variable in process.env and import.meta.env. Use vi.unstubAllEnvs to restore values changed with this helper.
Last updated
Syntax
function stubEnv<T extends string>(name: T, value: T extends 'PROD' | 'DEV' | 'SSR' ? boolean : string | undefined): VitestIn-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
vi.unstubAllEnvsimport.meta.envprocess.envunstubEnvs