Skip to content

test: make snapshot path matching CWD-agnostic#61846

Open
drtootsie wants to merge 2 commits intonodejs:mainfrom
drtootsie:fix-cwd-agnostic-snapshot-tests
Open

test: make snapshot path matching CWD-agnostic#61846
drtootsie wants to merge 2 commits intonodejs:mainfrom
drtootsie:fix-cwd-agnostic-snapshot-tests

Conversation

@drtootsie
Copy link

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

Pepper Pancoast added 2 commits February 15, 2026 14:37
Fixes: nodejs#61586

When a branch is entirely on ignored lines (via c8 ignore comments),
it should not appear in the BRDA output at all, rather than appearing
with 0 coverage.

Modified the branch coverage logic to check if all lines in the branch
are ignored before adding to branchReports and incrementing totalBranches.
This ensures ignored branches don't pollute coverage reports.
Fixes: nodejs#61303

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

Added negative lookahead (?![\w/]) to the regex patterns to ensure
only complete path segments are matched, preventing partial matches
in directory names and URLs.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-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
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_runner Issues 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

2 participants