Skip to content

Commit

Permalink
feat(vitest): stop using NODE_ENV to set vitest mode
Browse files Browse the repository at this point in the history
  • Loading branch information
adriencaccia committed Oct 30, 2023
1 parent 51b3c43 commit 3c4c9ce
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/vitest/src/node/cli-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function startVitest(
): Promise<Vitest | undefined> {
process.env.TEST = 'true'
process.env.VITEST = 'true'
process.env.NODE_ENV ??= options.mode || 'test'
process.env.NODE_ENV ??= 'test'

if (options.run)
options.watch = false
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function createVitest(mode: VitestRunMode, options: UserConfig, vit
logLevel: 'error',
configFile: configPath,
// this will make "mode": "test" | "benchmark" inside defineConfig
mode: options.mode || mode || process.env.NODE_ENV,
mode: options.mode || mode,
plugins: await VitestPlugin(options, ctx),
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function createPool(ctx: Vitest): ProcessPool {
env: {
TEST: 'true',
VITEST: 'true',
NODE_ENV: ctx.config.mode || 'test',
NODE_ENV: process.env.NODE_ENV || 'test',
VITEST_MODE: ctx.config.watch ? 'WATCH' : 'RUN',
...process.env,
...ctx.config.env,
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/node/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export async function initializeProject(workspacePath: string | number, ctx: Vit
root,
logLevel: 'error',
configFile,
// this will make "mode" = "test" inside defineConfig
mode: options.mode || ctx.config.mode || process.env.NODE_ENV,
// this will make "mode": "test" | "benchmark" inside defineConfig
mode: options.mode || ctx.config.mode,
plugins: [
...options.plugins || [],
WorkspaceVitestPlugin(project, { ...options, root, workspacePath }),
Expand Down

0 comments on commit 3c4c9ce

Please sign in to comment.