Repository navigation
test: check every mapping the library writes - #297
Conversation
`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
|
|
Warning Review limit reachedNext included review available in 6 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
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. Comment |
One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via: Supported
Alternatively, if the co-author should not be included, remove the Please update your commit message(s) by doing |
|
EasyCLA is red because it can't match the Generated by Claude Code |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 26.74%
|
|
CodSpeed Performance Analysis is red, but the regression doesn't come from this PR. The PR changes only CodSpeed also flags "Different runtime environments detected" for this comparison. Its biggest deltas are memory benchmarks that allocate once, for example Generated by Claude Code |
Summary
The test suite used to validate every mapping the library wrote, through
test/__mocks__/createMappingsSerializer.js. That check had silently stopped running:jest.requireActual("../createMappingsSerializer")path doesn't exist;getFromStreamChunksandstreamAndGetSourceAndMapnow write throughcreateMappingsWriter.#292 removed the file as dead code. This PR brings the check back for the current writer.
test/helpers/validate-mappings.jsreplaces the module'screateMappingsWriterexport before any library file loads, so every writer the library creates validates each mapping:sourceIndex === -1) has no original position or name;A stream that breaks these rules now fails the test that produced it. Without the check, it's encoded into a quietly wrong
mappingsstring. For example, a source that streams line 1 column 5 and then column 2 throughConcatSource.map()returns"KAAA"without the check, silently dropping the second mapping, and throws with it.One file serves both runners:
node --testloads it with--requirein thetest,test:coverageandtest:update-snapshotsscripts, and Jest loads it withsetupFiles.What kind of change does this PR introduce?
test
Did you add tests for your changes?
The change is a test harness check. Verification:
node --teston 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.test/helpers-unit.jsfed the writer a synthetic stream whose source-less segments carried original positions, which the library never produces. Those segments now use-1like the library does. The test still compares writer and serializer output, and still forces the writer's buffer to grow.node --testand Jest.npm run lint,npm run fmt:checkandnpm run test:coveragepass. Coverage still counts onlylib/.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:testand wrote this replacement.🤖 Generated with Claude Code
https://claude.ai/code/session_01ThsbPWvW5vnYWEaFs2Q22F
Generated by Claude Code