Skip to content
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

Avoid returning values in describe blocks #38

Conversation

rubennorte
Copy link
Contributor

@rubennorte rubennorte commented Mar 14, 2019

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 in describe 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 API

How: 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.

@codecov-io
Copy link

Codecov Report

Merging #38 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #38   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      1           
  Lines         120    119    -1     
  Branches       28     28           
=====================================
- Hits          120    119    -1
Impacted Files Coverage Δ
src/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a174a76...c3bafe2. Read the comment docs.

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes total sense. Thank you!

@kentcdodds kentcdodds merged commit f3d7b5b into babel-utils:master Mar 14, 2019
@rubennorte rubennorte deleted the avoid-returning-values-in-describe-blocks branch March 14, 2019 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants