Skip to content

fix: not.deep.oneOf failure message is missing the not - #1822

Merged
43081j merged 1 commit into
chaijs:mainfrom
chatman-media:fix/oneof-deep-negated-message
Jul 7, 2026
Merged

43081j merged 1 commit into
chaijs:mainfrom
chatman-media:fix/oneof-deep-negated-message

Conversation

@chatman-media

@chatman-media chatman-media commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Found this while poking around oneOf. In the plain (non-contains) deep branch, the positive and negative messages passed to this.assert are identical - looks like the negative one got copy-pasted without updating it:

this.assert(
  list.some(function (possibility) {
    return eql(expected, possibility);
  }),
  'expected #{this} to deeply equal one of #{exp}',
  'expected #{this} to deeply equal one of #{exp}', // same as above
  ...

So a failing expect(x).to.not.deep.oneOf([...]) prints "expected X to deeply equal one of Y" with no "not", which reads like the assertion passed. The contains branch right above it and the non-deep else branch right below both already have distinct pass/fail wording, so this looks like a straightforward oversight rather than intentional.

Fixed by adding "not" to the negative message, and added a test asserting on the actual message text for a failing negated case (the existing oneOf test only covers the passing path for plain deep.oneOf).

The negative message for the plain (non-contains) deep branch of oneOf
was copy-pasted from the positive one, so a failing .not.deep.oneOf()
assertion reads as if it passed. Added a test that checks the message
text on a failing negated case.
@chatman-media
chatman-media requested a review from a team as a code owner July 2, 2026 21:50
@43081j
43081j merged commit 53f9484 into chaijs:main Jul 7, 2026
6 checks passed
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