Skip to content

Conversation

@Aashish-Jha-11
Copy link
Contributor

Description

Adds comprehensive JSDoc documentation for the containSubset assertion that was added in #1664 but was never documented.

Changes Made

BDD Interface (lib/chai/core/assertions.js)

  • Enhanced JSDoc for .containSubset() method with detailed descriptions
  • Added multiple code examples showing:
    • Object subset matching
    • Array subset matching
    • Nested structure comparisons
    • Function validators
    • Date object comparisons
    • Negation with .not
    • Custom error messages
  • Documented the subset parameter
  • Documented the optional msg parameter

Assert Interface (lib/chai/interface/assert.js)

  • Enhanced JSDoc for assert.containsSubset()
  • Enhanced JSDoc for assert.doesNotContainSubset()
  • Added clear examples for both methods
  • Documented function validator behavior
  • Clarified the relationship between the two methods

Testing

  • All existing tests pass (510 passing)
  • No new functionality added, only documentation improvements
  • Lint checks pass

Fixes

Closes #1738

Additional Notes

This documentation follows the same format and style as other assertions in the codebase (e.g., .include(), .equal(), etc.). The documentation will be picked up by the documentation generation tools to update https://www.chaijs.com/api/bdd/

- Enhanced JSDoc for .containSubset() in BDD interface with detailed examples
- Documented object and array comparison behavior
- Added examples for nested structures, function validators, and Date objects
- Improved assert.containsSubset() documentation with clear examples
- Enhanced assert.doesNotContainSubset() documentation
- Added optional message parameter documentation

Fixes chaijs#1738
@Aashish-Jha-11 Aashish-Jha-11 requested a review from a team as a code owner November 8, 2025 16:38
43081j
43081j previously approved these changes Nov 10, 2025
Copy link
Contributor

@43081j 43081j left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me 👍

thanks for the help 🙏

Co-authored-by: James Garbutt <43081j@users.noreply.github.com>
@Aashish-Jha-11
Copy link
Contributor Author

Thanks a lot for the review and suggestions! Happy to contribute 😊

@43081j 43081j merged commit 40e6eb1 into chaijs:main Nov 10, 2025
6 checks passed
@Aashish-Jha-11 Aashish-Jha-11 deleted the docs/add-containSubset-documentation branch November 11, 2025 03:43
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.

Missing containSubset documentation

2 participants