-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Promise rejections are not handled #8
Comments
This is a very annoying problem. It took me a while to realise it was being caused because of jest-chain. Would be great if you could fix it. |
Any news on this? I'd really like to start using jest-chain, but this issue puts me off :-( |
I think there might be a bit of a conflict between |
@dobesv Am I using this correctly? await expect(rbac.can(ERole.user, EOperation.postSave))
.rejects.toBeInstanceOf(RbacProgrammaticException)
.rejects.toMatchObject({
name: "RbacProgrammaticException"
}); or expect(Promise.resolve(rbac.can(ERole.user, EOperation.postSave)))
.rejects.toBeInstanceOf(RbacProgrammaticException)
.rejects.toMatchObject({
name: "RbacProgrammaticException"
}); I get
It works like so: await (await expect(rbac.can(ERole.user, EOperation.postSave))
.rejects.toBeInstanceOf(RbacProgrammaticException))
.rejects.toMatchObject({
name: "RbacProgrammaticException"
}); |
@InsOpDe I'm not sure my change (assuming you are running the code from my PR) allows actually chaining on |
@InsOpDe Actually I see from the tests I added that this would have worked for |
@dobesv "jest-chain": "git://github.com/dobesv/jest-chain#promise-support", So yes, im certain that I have your codebase. |
Hmm, you know, it looks like the issue might be in the typescript types not reflecting the change. I'm not sure how best to address that ... Maybe if you hand-edit the typescript spec to change
If that works I could push the same change to my branch. |
With this change i would not get any type-error 👍 |
@InsOpDe Thanks for your help, I've updated the PR. Now it's just up to the project maintainer(s) to take a look at it. |
Sorry for the delay in coming to this! This should be fixed in: https://www.npmjs.com/package/jest-chain/v/1.1.6 @dobesv thanks for all of your help in this issue and your PR! |
Bug
package
version: 1.0.2node
version: 10.13.0yarn
version: 1.12.3Relevant code or config
See https://jestjs.io/docs/en/expect#rejects
What you did:
Neither of the above scenarios works with jest-chain. I haven't looked into how jest currently deals with promises but it seems that jest-chain breaks the expected behavior.
What happened (please provide anything you think will help):
The tests pass regardless of whether or not the promises throw. This seems related to #1
The text was updated successfully, but these errors were encountered: