feat(globals): make test return values stricter#10512
Conversation
thymikee
left a comment
There was a problem hiding this comment.
I think it's worth to note that this is TS only and doesn't affect runtime, so breaking only for TS users.
| - `[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.
this actually affects jest-types only?
There was a problem hiding this comment.
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 :) |
| }); | ||
| }; | ||
|
|
||
| returnedValue = fn.call< |
|
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/globalstodonecallback 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