-
Notifications
You must be signed in to change notification settings - Fork 117
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
toInclude doesn't work with Map object #176
Comments
It'd be The trick here is that there's not a clean way to identify that something is a Map. You can easily work around this by doing (official |
Thanks for that nicer shorthand :) Why wouldn't something like this work: if (value instanceof Map) {
// handle (expect(Map))
} Is there some edge case with false positives/negatives that I'm not considering? |
|
How unreliable is instanceof in a nodejs environment? I'm sure I don't speak for everyone, but I don't ever see myself using expect within a browser. Would it be possible to detect these environments and warn about this being unreliable in those cases, but allow it when in an environment that supports it? |
@bschlenk you have no idea if any of your dependencies are giving you an object that came from another realm, so, just as unreliable as in a browser. Separately, no, it would be a very bad idea for behavior to be environment-dependent (as opposed to capability-dependent) - that would be very confusing and error-prone to code. |
Detecting native or es6-shimmed Map/Set is doable via an abstraction; detecting core-js-shimmed Map/Set reliably is possible as of v2.5.1+ (iirc). This seems like a reasonable enhancement to consider. |
Example:
Error: Expected Map (3) {'a' => 'a', 'b' => 'b', 'c' => 'c'} to include { b: 'b' }
The text was updated successfully, but these errors were encountered: