-
Notifications
You must be signed in to change notification settings - Fork 109
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/isRejected is not perfect #166
Comments
Yup. Just FYI we've split the majority of the check-error logic into it's own module - https://github.com/chaijs/check-error - which is on npm and can be used like any normal dependency. While there is still quite a bit of code in our |
Jeez that is still a lot of code. Well I guess maybe it's easier now. |
Yeah... it's mostly argument munging or negotiating with the check-error API which we didn't want to black box. Sadly providing 10 different ways for people to assert on errors can make things complicated 😅 |
I have some tests that I'm sure are not testing what they appear to be testing because I did not realize that As for the other issues:
So I can see putting in a PR that fixes #47, #64 and #113. It could happen that #79 and #128 are fixed while I work on the other issues (I can easily see #128 being fixed as a side effect fixing something else) but it does not feel right to declare that I'll deal with them when neither are pressing issues for me. |
A pull request would be super-awesome. Thank you so much. |
@domenic I see test suite code that uses Mocha's I need to make some changes to |
I think in a library focused on adding complex promise features it's best not to rely on the promise features in the test runner. I'd rather keep it using the |
I've run into a bizarre problem that is tangentially related to what I said I'd fix but I'm at a point where input would be useful. The following code was run with [email protected] and [email protected]. Check "1" fails in a surprising way. The only trivial way I know how to prevent the surprising failure would be to make the
When I run it, I get:
|
We have a separate issue where |
Looking at #113 I took from this comment and this one that the preferable solution to the issue here would be to use This being said, I'm actually not seeing anything actionable in #85. A good deal of the issues there are issue with things other than chai-as-promised or they look like misconceptions to me. (ETA: I actually tried to reproduce the problems reported there, and could not.) |
This makes it impossible to get/view/report the error stack, because the stack is basically thrown away. Here's an example: wallaby.js uses it("should test promise throwing error", () => {
const promiseThrowingError = () => {
return new Promise((resolve, reject) => {
// or just throw new Error("Error from promise");
return reject(new Error("Error from promise"));
});
};
return expect(promiseThrowingError()).to.not.be.rejected;
}); the error stack can be reported in The raised Is there any way the original error could still be reported so that tools like test runners/reporters could report the error stack? |
Perhaps /cc @keithamus |
@ArtemGovorov Chai-as-promised 6 aims to mirror what Chai does. (See here for instance.) Did you try to see what you get when you do a test similar to the one you show in your earlier comment but which tests synchronous exception throwing? Do you get a stack then? I would expect not. Chai has Note that Chai-as-promised also benefits from |
@lddubeau I see what you mean about mirroring chai semantics. I think there's still an issue of not reporting the caught error back to the test runner though. This patch makes Using the |
Turning on
This stack doesn't tell me which test is failing. |
Ideally it should behave the same as Chai's error assertions. But it doesn't. Here's a meta-bug tracking all the previous bugs people have opened. Add your problem as a comment here.
rejectedWith
not reading constructor names #64 output not correctrejected
rejects if returned reason is a rejecting thenable #79 problems if rejection reason is a thenableThe solution is #47 (comment) if someone has the time to make that work. It looks like chaijs/chai#683 was merged so maybe Chai has the ability to do this now?
The text was updated successfully, but these errors were encountered: