Skip to content

test: avoid overmatching project root in snapshots#63254

Open
YsRza wants to merge 1 commit into
nodejs:mainfrom
YsRza:test-cwd-agnostic-snapshot-paths
Open

test: avoid overmatching project root in snapshots#63254
YsRza wants to merge 1 commit into
nodejs:mainfrom
YsRza:test-cwd-agnostic-snapshot-paths

Conversation

@YsRza
Copy link
Copy Markdown

@YsRza YsRza commented May 11, 2026

Summary

Update snapshot path normalization to avoid replacing project-root path text inside unrelated strings.

When the Node.js checkout lives in a short path such as /node, the current project-root transform can also match text inside values like https://nodejs.org or /node_modules. This can corrupt normalized output and make snapshot tests depend on the current working directory.

Changes

  • Adds a path-boundary check when creating the project-root replacement regex.
  • Keeps replacements for real paths such as /node/test/file.js.
  • Avoids replacing /node inside https://nodejs.org and /node_modules.

Validation

  • git diff --check
  • Manual boundary check with node -e

I also tried running node test/parallel/test-node-output-v8-warning.mjs, but this local environment failed to spawn the child process with EPERM.

Refs: #61303

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels May 11, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.03%. Comparing base (1a02250) to head (af029ed).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63254      +/-   ##
==========================================
+ Coverage   90.02%   90.03%   +0.01%     
==========================================
  Files         713      713              
  Lines      224950   224950              
  Branches    42536    42537       +1     
==========================================
+ Hits       202504   202528      +24     
+ Misses      14233    14190      -43     
- Partials     8213     8232      +19     

see 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants