-
-
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
Warn if describe returns a value #7852
Conversation
Just noticed |
It probably is - we had a test at work with an |
48e4d52
to
93f23e6
Compare
9831585
to
f17bcce
Compare
I've updated the PR to only |
Unfortunately couldn't find an easy way to print a nice one in those files, but at least it does contain the |
6b64186
to
afa46bc
Compare
Updated e2e tests to snapshot stdout instead of just matching a few of the lines. I think this is ready now |
Codecov Report
@@ Coverage Diff @@
## master #7852 +/- ##
==========================================
+ Coverage 63.31% 64.09% +0.77%
==========================================
Files 263 264 +1
Lines 10266 10218 -48
Branches 2098 1836 -262
==========================================
+ Hits 6500 6549 +49
+ Misses 3273 3262 -11
+ Partials 493 407 -86
Continue to review full report at Codecov.
|
@thymikee thoughts? |
Love it. I'm thinking that maybe it would be better to leave the warning title yellow and the rest of the message (or at least code frame) in default color? |
It's yellow due to |
I'd go with |
5328444
to
cf17d6a
Compare
Cool! Should hold off on merging this until we land the massive #7970 |
Rebase now that we've merged the jasmine PR? 🙂 |
Aye |
cf17d6a
to
0c8038e
Compare
CoffeeScript implicit `return`s trigger a warning since `describe` [should not](jestjs/jest#7852) `return` a value.
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
As the troubleshooting docs state, tests must be defined synchronously. This PR aims to prevent a class of errors where describe is used with an async function by printing a dedicated error message instead of "Your test suite must contain at least one test)", which usually appears if something is awaited before the
it
calls.Would have saved these people.
Unfortunately does not protect against this one though, and we'd need static analysis to save people from top-level awaits.
This could be considered breaking, especially if someone can think of a legitimate use case for returning a Promise (or anything at all) from
describe
. Or it could be considered non-breaking because returning a Promise (or anything at all) fromdescribe
was never supported. Hopefully FB doesn't do it 😅Test plan
New e2e test green with and without
JEST_CIRCUS=1
.