Skip to content

Conversation

@Himanshu197200
Copy link

@Himanshu197200 Himanshu197200 commented Nov 22, 2025

Summary (#1708)

This PR fixes a long-standing issue where Chai's inspect wrapper
accidentally enables loupe's string-based custom inspection behavior,
causing collisions with user-defined .inspect() methods.

Because Chai hardcodes the options passed to loupe's inspect and does
not currently expose a way to configure customInspect, loupe ends up
calling any object's enumerable .inspect() method—even if it is not
intended as a Node.js inspection hook.

This results in objects being printed incorrectly or throwing errors
when their .inspect() method expects different parameters.

Root Cause

loupe still interprets a plain string-keyed .inspect property as a
custom inspector when customInspect is true. Since Chai does not set
this option, the default behavior triggers unintentionally.

Fix

This PR explicitly sets:

customInspect: false

@Himanshu197200 Himanshu197200 requested a review from a team as a code owner November 22, 2025 20:28
@Himanshu197200
Copy link
Author

@keithamus plz review this PR.

@43081j
Copy link
Contributor

43081j commented Nov 23, 2025

is this not already fixed by chaijs/loupe#114?

we removed inspect from loupe itself, and now require users to use a Symbol to set it instead

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