Avoid returning values in describe blocks #38
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What: This modifies the
describe
blocks generated by the tester to avoid returning promises.Why: Even though this use case is "correct", using
async
functions indescribe
blocks (or returning promises, in general) is a common programmer error as Jest doesn't allow tests to be defined asychronously. Jest >=24.3.0 starts warning against this (jestjs/jest#7852) and it will be an error in Jest 25. This makes the necessary changes to avoid the warning and a possible future error, while maintaining the same external APIHow: I removed the return values for the
describe
blocks and updated all tests to mimic how Jest collects tests to wait for them to finish (instead of awaiting the promise we were returning previously).Disclaimer: I'm a Jest core maintainer.