Skip to content

Commit

Permalink
fix: process.env timeing
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Mar 17, 2022
1 parent 7b21be8 commit 5def681
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/vitest/src/node/cli-api.ts
Expand Up @@ -15,6 +15,10 @@ export interface CliOptions extends UserConfig {
}

export async function startVitest(cliFilters: string[], options: CliOptions, viteOverrides?: ViteUserConfig) {
process.env.TEST = 'true'
process.env.VITEST = 'true'
process.env.NODE_ENV ??= options.mode || 'test'

if (options.run)
options.watch = false

Expand All @@ -28,10 +32,7 @@ export async function startVitest(cliFilters: string[], options: CliOptions, vit

const ctx = await createVitest(options, viteOverrides)

process.env.TEST = 'true'
process.env.VITEST = 'true'
process.env.VITEST_MODE = ctx.config.watch ? 'WATCH' : 'RUN'
process.env.NODE_ENV ??= ctx.config.mode || 'test'

if (ctx.config.coverage.enabled) {
if (!await ensurePackageInstalled('c8')) {
Expand Down

0 comments on commit 5def681

Please sign in to comment.