Skip to content

test: check every mapping the library writes - #297

Merged
alexander-akait merged 1 commit into
mainfrom
claude/update-deps-github-actions-5ydose
Sep 26, 2026
Merged

alexander-akait merged 1 commit into
mainfrom
claude/update-deps-github-actions-5ydose

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

The test suite used to validate every mapping the library wrote, through test/__mocks__/createMappingsSerializer.js. That check had silently stopped running:

  • the mock was never loaded, because its jest.requireActual("../createMappingsSerializer") path doesn't exist;
  • it wrapped the serializer's default export, but getFromStreamChunks and streamAndGetSourceAndMap now write through createMappingsWriter.

#292 removed the file as dead code. This PR brings the check back for the current writer.

test/helpers/validate-mappings.js replaces the module's createMappingsWriter export before any library file loads, so every writer the library creates validates each mapping:

  • generated positions only move forward: line, then column within a line;
  • a segment without a source (sourceIndex === -1) has no original position or name;
  • a segment with a source has valid original fields.

A stream that breaks these rules now fails the test that produced it. Without the check, it's encoded into a quietly wrong mappings string. For example, a source that streams line 1 column 5 and then column 2 through ConcatSource.map() returns "KAAA" without the check, silently dropping the second mapping, and throws with it.

One file serves both runners: node --test loads it with --require in the test, test:coverage and test:update-snapshots scripts, and Jest loads it with setupFiles.

What kind of change does this PR introduce?

test

Did you add tests for your changes?

The change is a test harness check. Verification:

  • Suite passes with the check: all 89,973 tests, including the Fuzzy combinations, under node --test on Node.js 22, Jest 30 on Node.js 20, and Jest 27 on Node.js 16 and 10. The library's current output is valid.
  • One unit test adjusted: a test in test/helpers-unit.js fed the writer a synthetic stream whose source-less segments carried original positions, which the library never produces. Those segments now use -1 like the library does. The test still compares writer and serializer output, and still forces the writer's buffer to grow.
  • The check fires in both runners: against the old synthetic stream, it fails that test under both node --test and Jest.
  • npm run lint, npm run fmt:check and npm run test:coverage pass. Coverage still counts only lib/.

Does this PR introduce a breaking change?

No, only tests change.

If relevant, what needs to be documented once your changes are merged or what have you already documented in this PR?

Nothing.

Use of AI

Claude Code found the dead mock while moving the tests to node:test and wrote this replacement.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ThsbPWvW5vnYWEaFs2Q22F


Generated by Claude Code

`test/__mocks__/createMappingsSerializer.js` validated each mapping, but it
was never loaded, and it wrapped the serializer's default export, which the
library no longer uses: `getFromStreamChunks` and `streamAndGetSourceAndMap`
write through `createMappingsWriter`. #292 removed it as dead code.

`test/helpers/validate-mappings.js` brings the check back for the writer.
It replaces the module's `createMappingsWriter` export before any library
file loads, so every writer checks that mappings come in generated order
and that a segment without a source has no original position or name. A
stream that breaks that now fails the test that produced it instead of
being encoded into a quietly wrong `mappings` string. `node --test` loads
it with `--require`, Jest with `setupFiles`, so one file serves both.

The whole suite passes with the check. The one exception was a unit test
feeding the writer a synthetic stream whose source-less segments carried
original positions; those segments now use -1 like the library does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ThsbPWvW5vnYWEaFs2Q22F
@changeset-bot

changeset-bot Bot commented Sep 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 21d4a87

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 6 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 9d15c150-3ee8-4a44-9af3-2674814dc7f3

📥 Commits

Reviewing files that changed from the base of the PR and between 5a9b34d and 21d4a87.

📒 Files selected for processing (4)
  • jest.config.js
  • package.json
  • test/helpers-unit.js
  • test/helpers/validate-mappings.js

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

Comment @coderabbitai help to get the list of available commands.

@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via:

Co-authored-by: name <email>

Supported Co-authored-by: formats include:

  1. Anything <[email protected]> - it will locate your GitHub user by id part.
  2. Anything <[email protected]> - it will locate your GitHub user by login part.
  3. Anything <public-email> - it will locate your GitHub user by public-email part. Note that this email must be made public on Github.
  4. Anything <other-email> - it will locate your GitHub user by other-email part but only if that email was used before for any other CLA as a main commit author.
  5. login <any-valid-email> - it will locate your GitHub user by login part, note that login part must be at least 3 characters long.

Alternatively, if the co-author should not be included, remove the Co-authored-by: line from the commit message.

Please update your commit message(s) by doing git commit --amend and then git push [--force] and then request re-running CLA check via commenting on this pull request:

/easycla

Copy link
Copy Markdown
Member Author

EasyCLA is red because it can't match the Claude co-author trailer on this commit to a GitHub account. That can't be fixed from the branch and needs a maintainer override, as on #292 and #293. Nothing else is failing so far.


Generated by Claude Code

@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.09%. Comparing base (5a9b34d) to head (21d4a87).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #297   +/-   ##
=======================================
  Coverage   99.09%   99.09%           
=======================================
  Files          27       27           
  Lines        6318     6318           
  Branches      807      806    -1     
=======================================
  Hits         6261     6261           
  Misses         56       56           
  Partials        1        1           
Flag Coverage Δ
integration 99.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

@codspeed

codspeed Bot commented Sep 26, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 26.74%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 7 improved benchmarks
❌ 16 regressed benchmarks
✅ 189 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory clear-cache memory: shared modules (no visited set — allocates per chunk) 6.6 KB 72.8 KB -90.94%
❌ Memory size-only-source memory: new SizeOnlySource() 58.9 KB 436.1 KB -86.49%
❌ Memory replace-source memory: construct + 100 insertions 38.1 KB 136.6 KB -72.13%
❌ Memory compat-source memory: delegated source() + map() through wrapper 9.9 KB 31 KB -68.19%
❌ Memory replace-source memory: source() concatenates result 37.7 KB 84.1 KB -55.18%
❌ Memory source-map-source memory: new SourceMapSource(simple) 1.4 KB 2.6 KB -46.27%
❌ Memory cached-source memory: warm sourceAndMap() returns cached references 209 B 369 B -43.36%
❌ Memory concat-source memory: source() concatenates children 189.8 KB 302.2 KB -37.19%
❌ Memory concat-source memory: map({ columns: true }) composes child maps 3 MB 4.3 MB -30.97%
❌ Memory source-map-source memory: sourceAndMap({ columns: true }) (combined inner) 1.7 MB 2.5 MB -30.39%
❌ Memory concat-source memory: new ConcatSource(...children) 4.3 KB 5.5 KB -21.99%
❌ Memory compat-source memory: new CompatSource(sourceLike) 1.3 KB 1.7 KB -21.23%
❌ Memory replace-source memory: map({ columns: true }) splices mappings 2.4 MB 2.9 MB -17.4%
❌ Memory source-map-source memory: map({ columns: true }) 1.3 KB 1.5 KB -16.33%
❌ Memory raw-source memory: new RawSource(string) 1.3 KB 1.5 KB -16.33%
❌ Memory prefix-source memory: source() allocates rewritten string 1.9 KB 2.2 KB -11.43%
⚡ Memory prefix-source memory: new PrefixSource() 14.9 KB 2.2 KB ×6.8
⚡ Memory original-source memory: new OriginalSource() 4.3 KB 2.1 KB ×2.1
⚡ Memory clear-cache memory: shared modules (visited set — single allocation) 1,384 B 912 B +51.75%
⚡ Memory cached-source memory: construct from cachedData (no warm-up) 784 B 544 B +44.12%
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing claude/update-deps-github-actions-5ydose (21d4a87) with main (5a9b34d)

Open in CodSpeed

Copy link
Copy Markdown
Member Author

CodSpeed Performance Analysis is red, but the regression doesn't come from this PR. The PR changes only test/, jest.config.js and the test scripts in package.json. It doesn't touch lib/ or benchmark/, and the benchmark scripts (npm run benchmark / benchmark:memory) don't load test/helpers/validate-mappings.js. So the benchmarked code is identical to main.

CodSpeed also flags "Different runtime environments detected" for this comparison. Its biggest deltas are memory benchmarks that allocate once, for example new SizeOnlySource() going from 58.9 KB to 436.1 KB. That is the same cross-host noise noted on #293. No fix is needed here; a maintainer can acknowledge the report on CodSpeed. I can't re-run the CodSpeed check from this session.


Generated by Claude Code

@alexander-akait
alexander-akait merged commit d3548f7 into main Sep 26, 2026
35 of 37 checks passed
@alexander-akait
alexander-akait deleted the claude/update-deps-github-actions-5ydose branch September 26, 2026 15:45
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