Skip to content

test: make snapshot path matching CWD-agnostic - #61846

Open
drtootsie wants to merge 1 commit into
nodejs:mainfrom
drtootsie:fix-cwd-agnostic-snapshot-tests
Open

test: make snapshot path matching CWD-agnostic#61846
drtootsie wants to merge 1 commit into
nodejs:mainfrom
drtootsie:fix-cwd-agnostic-snapshot-tests

Conversation

@drtootsie

Copy link
Copy Markdown

Fixes: #61303

Summary

The snapshot path transformation was incorrectly matching partial paths like /node within /node_modules or nodejs.org, causing false replacements.

Changes

Added negative lookahead (?![\\w/]) to the regex patterns in test/common/assertSnapshot.js to ensure only complete path segments are matched.

This prevents partial matches in:

  • Directory names (e.g., /node_modules)
  • URLs (e.g., nodejs.org)
  • Other paths containing the CWD as a substring

Testing

Requires building Node.js and running the test suite:

./configure && make -j4
make test-only

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Feb 15, 2026
Comment threadlib/internal/test_runner/coverage.js Outdated
if (range.count !== 0 ||
range.ignoredLines === range.lines.length) {
branchesCovered++;
// Skip branches that are entirely on ignored lines

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No that's from #61845

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollinamcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 16, 2026
@codecov

codecovBot commented Feb 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.65%. Comparing base (3dff7ef) to head (e291c5c).
⚠️ Report is 1321 commits behind head on main.

Additional details and impacted files
@@ Coverage Diff @@## main #61846 +/- ##
==========================================
- Coverage 91.63% 89.65% -1.99% 
==========================================
Files 337 676 +339 Lines 140596 206546 +65950 Branches 21789 39551 +17762 ==========================================
+ Hits 128835 185173 +56338 - Misses 11535 13480 +1945 - Partials 226 7893 +7667 

see 459 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.

@aduh95aduh95 removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 16, 2026

@cjihrigcjihrig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you separate out the unrelated changes please.

@drtootsie
drtootsieforce-pushed the fix-cwd-agnostic-snapshot-tests branch from f95913e to 975d553CompareFebruary 22, 2026 05:48
@drtootsie
drtootsieforce-pushed the fix-cwd-agnostic-snapshot-tests branch from 381c9a7 to e291c5cCompareMarch 10, 2026 02:51
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

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

Labels

needs-ciPRs that need a full CI run.staletest_runnerIssues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some tests are not fully CWD-agnostic

7 participants

@drtootsie@nodejs-github-bot@mcollina@cjihrig@MoLow@aduh95@avivkeller