Repository navigation
📦🔥:describe any value in an assertion message - #94
Conversation
assertEqual and six guard factories built their messages with String, which throws a TypeError for an object without a prototype or one whose toString throws. The assertion then failed with that TypeError rather than an AssertionError naming what was expected. assertValue already guarded against this, so its describer moves to an internal module and every message uses it. Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is> Assisted-by: Claude-Code:claude-opus-5
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (17)
Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour. 📝 WalkthroughWalkthroughThe change adds a shared helper to format values in assertion failure messages and guard expectations. Equality and comparison logic remains unchanged. Tests cover null-prototype values, and a patch changeset describes the update. ChangesAssertion value formatting
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Change: Bug fix · Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to This change makes assertion failure messages safe for values such as prototype-less objects, so they report an assertion error instead of a TypeError. No merge-blocking risk was identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Requested by DerekNonGeneric
Before:
assertEqual(Object.create(null), 1)threwTypeError: Cannot convert object to primitive valueinstead of anAssertionError. The same happened with the expectation ofisEqualTo,isIdenticalToand the four relational guard factories whenever the expected value had no prototype.After: these messages describe the value the way
assertValuealready did, so the failed assertion is what gets reported.How:
assertValue'sstringifyValuemoves to_internal/_stringify-value.tsand every message builder uses it. Seven tests fail on main and pass here.Summary by CodeRabbit