-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add change/increase/decrease assertions with generic type support #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive change tracking assertions for monitoring value mutations during function execution. It introduces three main assertion types (change/increase/decrease) with support for delta validation via .by() chaining, covering both getter functions and object properties.
Changes:
- Added 12 new assertion methods (change/changes, increase/increases, decrease/decreases and their variants with By suffix)
- Created new interfaces and type definitions for change tracking (IChangeResultOp, IChangeResultValue, ChangeFn, ChangeByFn)
- Updated Chai compatibility shim with all change assertions and enabled previously commented tests
- Added comprehensive test coverage across multiple test files
- Enhanced scopeContext with symbol-based _$details getter for debugging
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/assert/funcs/changes.ts | New implementation for change/increase/decrease assertions |
| core/src/assert/funcs/changesBy.ts | New implementation for changeBy/increaseBy/decreaseBy assertions |
| core/src/assert/ops/changeResultOp.ts | New operation for .by() chaining support |
| core/src/assert/interface/ops/IChangeResultOp.ts | Interface for change result with .by() chaining |
| core/src/assert/interface/ops/IChangeResultValue.ts | Interface for change metadata |
| core/src/assert/interface/funcs/ChangeFn.ts | Function signature for change assertions |
| core/src/assert/interface/funcs/ChangeByFn.ts | Function signature for changeBy assertions |
| core/src/assert/interface/ops/IToOp.ts | Updated with 12 new assertion methods and documentation |
| core/src/assert/interface/IAssertInst.ts | Updated with 12 new assertion methods |
| core/src/assert/interface/IAssertClass.ts | Updated with 24 assert.* methods, fixed typo in comment |
| core/src/assert/interface/IAssertClassDef.ts | Fixed typo: "accert" to "assert" |
| core/src/assert/internal/_isMsgSource.ts | New helper to validate MsgSource type |
| core/src/assert/internal/_baseFunctions.ts | Added change assertions to core functions |
| core/src/assert/ops/toOp.ts | Registered all new change assertions |
| core/src/assert/assertClass.ts | Added 12 assert.* method definitions with nArgs |
| core/src/assert/assertScope.ts | Updated debug logging prefix |
| core/src/assert/scopeContext.ts | Added symbol-based _$details getter for debugging |
| core/src/assert/adapters/exprAdapter.ts | CRITICAL: Contains commented-out code |
| core/src/assert/adapters/evalAdapter.ts | Updated debug logging prefix |
| core/src/index.ts | Exported new interfaces and types |
| shim/chai/src/assert/chaiAssert.ts | Implemented all change assertions for Chai compatibility |
| shim/chai/test/src/chaiAssert.test.ts | Enabled and updated previously commented tests |
| core/test/src/assert/expect.change.test.ts | New comprehensive test file for expect-style assertions |
| core/test/src/assert/assert.changes.test.ts | New comprehensive test file for assert-style assertions |
| core/test/src/assert/assert.property.test.ts | Enhanced property assertion tests |
| core/test/src/assert/assert.oneOf.test.ts | Added missing test assertion for Map entry |
| core/test/src/assert/adapters/exprAdapter.test.ts | New comprehensive adapter tests for scope function isolation |
e9722d2 to
412fe7a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 2 comments.
e2a3310 to
a988566
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
Add comprehensive change tracking assertions for monitoring value mutations during function execution. Supports both getter functions and object properties with optional delta validation via .by() chaining. New Assertion Types: - change/changes: Track any value change (direction-agnostic) - increase/increases: Track positive value changes - decrease/decreases: Track negative value changes - changeBy/changesBy: Direct delta validation (sign-agnostic) - increaseBy/increasesBy: Positive delta validation - decreaseBy/decreasesBy: Negative delta validation Implementation: - Added ChangeFn and ChangeByFn function interfaces for type safety - Created IChangeResultOp interface for .by() chaining support - Added IChangeResultValue interface for change metadata - Created changeResultOp helper for .by() chain functionality Integration: - Updated IToOp interface with all 12 change assertion methods - Updated IAssertInst interface with matching methods - Updated IAssertClass with 24 assert.* methods (all variants) - Added all methods to coreFunctions and toOp registrations - Updated scopeContext with symbol-based _$details getter for easier debugging Documentation: - Added comprehensive TypeDoc with @param, @example, and @alias tags - Documented both getter function and object property usage patterns - Clarified sign-agnostic behavior for changeBy/changesBy - Emphasized positive delta requirement for increase/decrease variants Testing: - Added exprAdapter tests for scope function isolation - Updated property tests with better assertions - Fixed oneOf test for Map entries Chai Compatibility: - Updated chaiAssert with all change/increase/decrease methods - Enabled previously commented Chai compatibility tests - All Chai shim tests now passing This enables powerful assertions like: expect(fn).to.change(obj, 'val').by(5) expect(fn).to.increase(getValue) assert.decreases(fn, obj, 'count')
a988566 to
4a5ae58
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 30 out of 30 changed files in this pull request and generated no new comments.
Add comprehensive change tracking assertions for monitoring value mutations during function execution. Supports both getter functions and object properties with optional delta validation via .by() chaining.
New Assertion Types:
Implementation:
Integration:
Documentation:
Testing:
Chai Compatibility:
This enables powerful assertions like:
expect(fn).to.change(obj, 'val').by(5) expect(fn).to.increase(getValue) assert.decreases(fn, obj, 'count')