test(translator): make nine fragment assertions fail when nothing is collected - #138
Merged
Merged
Conversation
…collected
An audit of the suite replaced `collectInlineFragments` with an implementation
that silently returns `[]` and ran the tests. Eleven of the forty-nine passed.
The mechanism was the same in every case: the assertion reached the value
through an optional chain, or ran a predicate over an array that was empty, so
it was satisfied by the absence of a result.
const fragment = collectInlineFragments(root)[0]?.fragments[0];
expect(fragment?.top).toBe(fragment?.node); // undefined === undefined
expect(containers.every((c) => c.skip !== undefined)).toBe(true); // [] → true
expect(containers.some((c) => c.node === link)).toBe(false); // [] → false
expect(collectInlineFragments(root)[0]?.skip).toBeUndefined(); // undefined
The worst of them was the check that a multi-leaf wrapper's `top` is a copy
rather than the wrapper from the tree — the distinction the whole module
exists for, passing against a collector that collected nothing.
Each now asserts that the container or fragment exists before asserting
anything about it. Re-running the same audit: eleven survivors down to two,
and those two are `toEqual([])` on an empty root and on a node with no text
children — assertions whose whole content is the absence, which is their
contract clause rather than an oversight.
Also drops the three `any`s from the `createNode` helper, which the repo's
lint does not flag but the project forbids.
Verification: 1469 unit tests, unchanged in count and all green; check-types
clean; lint 58 warnings and 0 errors, identical to main.
SearheiParkhamchuk
requested review from
ChiefCreator and
dogfrogfog
as code owners
September 11, 2026 12:30
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🎉 This PR is included in version 0.13.0 🎉 The release is available on npm package (@latest dist-tag) Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up on #137, found by auditing its own suite.
How they were found
A throwing stub proves little — every check goes red because everything explodes. The harder question is what survives an implementation that returns nothing, quietly.
collectInlineFragmentswas replaced with() => []and the suite re-run:Why they passed
One mechanism, four spellings — the assertion reaches its value through an optional chain, or runs a predicate over an array that is empty:
The most uncomfortable one was
gives a multi-leaf wrapper's fragment a copy of the wrapper as top, not the wrapper— the distinction the module is built around — passing against a collector that returns an empty array.The fix
Each check now asserts the container or fragment exists before asserting anything about it. No production code changed.
Re-running the same audit afterwards: 11 survivors → 2. Those two are
toEqual([])for an empty root and for a node with no text children — checks whose entire content is the absence, which is their contract clause rather than an oversight. Strengthening them would mean asserting something they do not claim.Also removes the three
anys from thecreateNodehelper.oxlintdoes not flag them; the project's own rule does.Verification
1469 unit tests, unchanged in count and all green. check-types clean. Lint 58 warnings, 0 errors — identical to
main.