-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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 inconsistency in rejects.toThrow()
#6678
Conversation
Seems like a reasonable change to me 🙂 While I agree everything thrown should be a subclass of Mind taking a look at the failing tests? This should also get a changelog entry 🙂 |
I am checking failed tests and this is confusing. // jest/packages/expect/src/__tests__/to_throw_matchers.test.js
test('passes', async () => {
await jestExpect(asyncFn(false, true)).resolves.not[toThrow]();
});
My fix if (fromPromise && /*isError(actual)*/) {
// ^^^^^^ removed this
error = actual;
} It doesn't make sense to use My suggestion would be to support |
I think that makes sense! Or throw a useful " |
@thymikee @rickhanlonii thoughts? |
@BetterCallSKY I use custom objects instead of subclasses of Error becuase there is a limitation in TypeScript when compiling to ES5 |
👍 If we can be consistent, let's do it. |
Does it make sense to split it to Examples // new
expect(value).promise.toEqual(expected);
// old
expect(value).resolves.toEqual(expected);
// new
expect(value).promise.toThrow(error);
// old
expect(value).rejects.toThrow(expected); https://jestjs.io/docs/en/expect I can submit a PR, but it will be a breaking change in the API. |
@SimenB wdyt? My take is we shouldn't drop |
This PR is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This PR was closed because it has been stalled for 30 days with no activity. Please open a new PR if the issue is still relevant, linking to this one. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
fixes #6675
With this fix sync and async versions of
toThrow
are consistent.However, throwing non-errors is not a good practice because we don't have the stack trace.