Skip to content

fix(config): override NODE_ENV in the client environment - #1882

Merged
danielroe merged 1 commit into
mainfrom
fix/node-env
Nov 2, 2026
Merged

danielroe merged 1 commit into
mainfrom
fix/node-env

Conversation

@danielroe

@danielroe danielroe commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

🔗 Linked issue

npmx-dev/npmx.dev#3376

📚 Description

with the vite environment API (Nuxt 5 or opt-in in Nuxt 4), process.env.NODE_ENV is overridden to production in browser tests.

that's because Nuxt defines it in the client environment configuration, which overrides the top-level define that we override, which means Vue's dev-only paths are compiled out and lots of things end up breaking

👉 this applies the same define overrides to the client environment when there is one.

@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nuxt/test-utils/@nuxt/test-utils@1882
npm i https://pkg.pr.new/nuxt/test-utils/vitest-environment-nuxt@1882

commit: 59bc78a

@danielroe
danielroe requested a review from yamachi4416 November 2, 2026 11:16
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8ddf7b5d-8d5c-4f0c-8e44-276abf9e22f6
Commits

Reviewing files that changed from the base of the PR and between 696d79c and 59bc78a.

Files selected for processing: 2
  • examples/app-vitest-workspace/app5/test/nuxt/emitted.spec.ts
  • src/config.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

Walkthrough

getVitestConfigFromNuxt now also applies test-mode define values to the client Vite environment when that environment exists. An example test mounts a Vue component, clicks its button, and checks that its ping event contains 1.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Minimal · up to 59bc7

The configuration safely applies the intended client NODE_ENV override without discarding existing client definitions.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: overriding NODE_ENV in the client environment.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description directly explains the changes to apply define overrides to the Vite client environment and addresses the reported process.env.NODE_ENV issue in browser tests.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/config.ts

Parsing error: Unexpected token {

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@danielroe
danielroe added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit ca39385 Nov 2, 2026
14 checks passed
@danielroe
danielroe deleted the fix/node-env branch November 2, 2026 13:45
@github-actions github-actions Bot mentioned this pull request Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants