-
-
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
feat(globals): make test return values stricter #10512
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worth to note that this is TS only and doesn't affect runtime, so breaking only for TS users.
@@ -4,6 +4,8 @@ | |||
|
|||
- `[jest-circus, jest-config, jest-runtime]` Add new `injectGlobals` config and CLI option to disable injecting global variables into the runtime ([#10484](https://github.com/facebook/jest/pull/10484)) | |||
- `[jest-each]` Fixes `.each` type to always be callable ([#10447](https://github.com/facebook/jest/pull/10447)) | |||
- `[jest-globals]` [**BREAKING**] Disallow return values other than a `Promise` from hooks and tests ([#10512](https://github.com/facebook/jest/pull/10512)) | |||
- `[jest-globals]` [**BREAKING**] Disallow mixing a done callback and returning a `Promise` from hooks and tests ([#10512](https://github.com/facebook/jest/pull/10512)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this actually affects jest-types
only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's just a types change, yeah. The global types that everybody uses today (including us) lives in DefinitelyTyped.
Yup. I wanna make Jest throw at runtime for these cases as well, FWIW. This PR is just types, tho. Could do both at same time? So the types reflect reality instead of the reality we want :) |
I don't have any preference as long as it lands with breaking changes in 27, so whatever is easier :) |
@@ -216,25 +226,17 @@ export const callAsyncCircusFn = ( | |||
}); | |||
}; | |||
|
|||
returnedValue = fn.call< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
Summary
This tweaks the types you get when importing from
@jest/globals
todone
callback with returning a promiseCode changes not in
packages/jest-types/src/Global.ts
(and the test) can land on master now. No rush, thoughTest plan
Type tests added, so green CI