Skip to content

Conversation

@nev21
Copy link
Contributor

@nev21 nev21 commented Jan 12, 2026

Implement comprehensive support for nested property assertions using dot notation (e.g., a.b.c) and bracket notation (e.g., a[0]).

New Assertions:

  • nestedProperty / notNestedProperty - Check nested properties with loose equality
  • deepNestedProperty / notDeepNestedProperty - Check nested properties with deep equality
  • nestedInclude / notNestedInclude - Match nested properties against expected object
  • deepNestedInclude / notDeepNestedInclude - Deep match nested properties

Features:

  • Dot notation: a.b.c
  • Bracket notation: a[0], a[b]
  • Mixed paths: a.b[0].c
  • Escape sequences: .a, [b] for literal dots/brackets

API Extensions:

  • Added INestedOp interface with property, include, includes, contain, contains methods
  • Integrated with IHasOp and IDeepOp operation chains
  • Supports both assert and expect syntax

Error Enhancements:

  • Added operator and showDiff readonly properties to AssertionError
  • Added showDiff configuration option (default: true)
  • Improved error messages with better context for nested property failures

Chai Shim:

  • Implemented nestedProperty, notNestedProperty, nestedPropertyVal, notNestedPropertyVal
  • Implemented deepNestedPropertyVal, notDeepNestedPropertyVal
  • Implemented nestedInclude, notNestedInclude, deepNestedInclude, notDeepNestedInclude

@nev21 nev21 added this to the 0.1.5 milestone Jan 12, 2026
Copilot AI review requested due to automatic review settings January 12, 2026 01:41
Copy link

Copilot AI left a 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 implements comprehensive nested property assertion support using dot notation (e.g., a.b.c) and bracket notation (e.g., a[0]), along with Chai.js compatibility. It adds new assertion functions for checking nested properties with both loose and deep equality, enhances error handling with showDiff and operator properties, and provides full integration with both assert and expect APIs.

Changes:

  • Added nested property operations with path parsing supporting dot notation, bracket notation, and escape sequences
  • Implemented nestedProperty, deepNestedProperty, nestedInclude, and deepNestedInclude assertions with negation variants
  • Enhanced AssertionError with readonly operator and showDiff properties for better error reporting
  • Integrated nested operations into IHasOp and IDeepOp interfaces for fluent API chaining

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
core/src/assert/funcs/nested.ts Implements path parsing and nested property assertion logic with support for dot/bracket notation
core/src/assert/ops/nestedOp.ts Creates operation wrappers for nested and deep nested property assertions
core/src/assert/interface/ops/INestedOp.ts Defines TypeScript interface for nested property operations
core/src/assert/ops/hasOp.ts Integrates nested operations into the has operation chain
core/src/assert/ops/deepOp.ts Integrates deep nested operations into the deep operation chain
core/src/assert/assertClass.ts Registers nested assertion functions in the main assert class
core/src/assert/assertionError.ts Adds readonly properties for operator and showDiff with helper function
core/src/assert/scopeContext.ts Includes showDiff in context details and fixes typo in documentation
core/src/assert/config.ts Adds default showDiff: true configuration option
core/src/assert/interface/IAssertConfig.ts Defines showDiff configuration property
core/src/assert/interface/IAssertClass.ts Adds TypeScript definitions for new nested assertion methods
core/src/assert/interface/ops/IHasOp.ts Extends interface with nested property operation
core/src/assert/interface/ops/IDeepOp.ts Extends interface with deep nested property operation
core/src/assert/funcs/hasProperty.ts Updates default error messages for property assertions
core/src/assert/ops/includeOp.ts Renames parameters for consistency
core/src/index.ts Exports INestedOp interface publicly
core/test/src/assert/parseNestedPath.test.ts Comprehensive tests for path parsing with various notations and edge cases
core/test/src/assert/assert.nested.test.ts Tests for all nested property assertion functions
core/test/src/assert/context.test.ts Updates tests to expect showDiff in context details
core/test/src/assert/assertionError.test.ts Tests for new readonly properties on AssertionError
core/test/src/support/checkError.ts Makes match parameter required (breaking change)
shim/chai/src/assert/chaiAssert.ts Implements Chai compatibility adapters for nested assertions
shim/chai/test/src/chaiAssert.test.ts Enables and updates Chai compatibility tests for nested operations

Implement comprehensive support for nested property assertions using dot notation (e.g., a.b.c) and bracket notation (e.g., a[0]).

New Assertions:
- nestedProperty / notNestedProperty - Check nested properties with loose equality
- deepNestedProperty / notDeepNestedProperty - Check nested properties with deep equality
- nestedInclude / notNestedInclude - Match nested properties against expected object
- deepNestedInclude / notDeepNestedInclude - Deep match nested properties

Features:
- Dot notation: a.b.c
- Bracket notation: a[0], a[b]
- Mixed paths: a.b[0].c
- Escape sequences: \.a, \[b\] for literal dots/brackets

API Extensions:
- Added INestedOp<R> interface with property, include, includes, contain, contains methods
- Integrated with IHasOp and IDeepOp operation chains
- Supports both assert and expect syntax

Error Enhancements:
- Added operator and showDiff readonly properties to AssertionError
- Added showDiff configuration option (default: true)
- Improved error messages with better context for nested property failures

Chai Shim:
- Implemented nestedProperty, notNestedProperty, nestedPropertyVal, notNestedPropertyVal
- Implemented deepNestedPropertyVal, notDeepNestedPropertyVal
- Implemented nestedInclude, notNestedInclude, deepNestedInclude, notDeepNestedInclude
@nev21 nev21 enabled auto-merge (squash) January 12, 2026 02:12
@nev21 nev21 merged commit b316fd5 into main Jan 12, 2026
10 checks passed
@nev21 nev21 deleted the nev21/nested branch January 12, 2026 02:21
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