-
Notifications
You must be signed in to change notification settings - Fork 108
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
rejectedWith
not reading constructor names
#64
Comments
I'm happy to raise a PR if you think I'm on the right tracks here… |
In general this seems like a special case of #47. I would prefer the solution outlined there (i.e., extract Chai's logic into a Chai util; release a new Chai version; depend on and use that logic). But a pull request for a small patch to make us match Chai's logic better would be OK too. |
I'm rolling up all bugs in the category "isRejected/rejectedWith doesn't behave like Chai's error rejectors" into #166. |
We now use the check-error package to get the constructor name of the error we expect to get with `rejectedWith`. For recent versions of Chai, this makes `rejectedWith` consistent in behavior with Chai's `throw`. Fixes chaijs#64.
We now use the check-error package to get the constructor name of the error we expect to get with `rejectedWith`. For recent versions of Chai, this makes `rejectedWith` consistent in behavior with Chai's `throw`. Fixes #64.
With plain Chai, if I do:
I get:
With Chai as Promised, if I do the equivalent:
I get:
Chai as Promised thinks that the
Array
constructor’s name isundefined
.I had a brief look into this: https://github.com/domenic/chai-as-promised/blob/d607a914ea8cff473f179becf8029a241ed011ee/lib/chai-as-promised.js#L152. Should we be reading the name property from the constructor function, instead of creating an instance and looking for a name on that? Alternatively the name could be read as
instance.constructor.name
. Here is what looks like the equivalent line but in Chai: https://github.com/chaijs/chai/blob/ab999d89171634e3b953765c6d0c8a7d454a4b59/lib/chai/core/assertions.js#L1054Also, the error message format is slightly difference compared to standard Chai. Is this intentional, out of curiosity?
The text was updated successfully, but these errors were encountered: