-
-
Notifications
You must be signed in to change notification settings - Fork 698
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
fix: .include
to work with all objects
#1012
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.
Awesome as always
LGTM
lib/chai/core/assertions.js
Outdated
return; | ||
// `_.expectTypes` isn't used here because `.include` should work with | ||
// objects with a custom `@@toStringTag`. | ||
if ((objType !== 'string' && objType !== 'object') || objType === 'null') { |
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.
Maybe we should move this check to default
to eliminate !== 'string'
check and use val === Object(val)
to avoid === 'null'
and allow functions?
Overly strict type-checking was causing `.include` to reject `Error` objects and objects with a custom `@@toStringTag`.
2b3bdb7
to
c01cf30
Compare
@shvaikalesh @vieiralucas Updated. |
Great job, @meeber. LGTM. |
This does not work. The following object still gives the error message:
When using:
Tested on both chai 4.1.1 and chai 4.1.2 |
@metareven According to the docs, I don't think you can use With that said, something is clearly not right with this error message and this PR in general. It's been quite awhile since I looked at the Chai codebase, but I'm thinking |
Overly strict type-checking was causing
.include
to rejectError
objects and objects with a custom
@@toStringTag
.Fixes #1009