-
-
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
[jest-each]: Add flag to prevent done callback being supplied to describe #6843
Conversation
2c1fede
to
0a81b2f
Compare
packages/jest-each/src/bind.js
Outdated
test: Function, | ||
) => { | ||
if (supportsDone && params.length < test.length) | ||
return done => test(...params, done); | ||
|
||
return () => test(...params); |
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.
nit: can we fold it to:
return supportsDone && params.length < test.length
? done => test(...params, done)
: () => test(...params)
same suggestion for applyObjectParams
below
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.
Like it! may as well drop the return
too 😜 what do you think of this?
const applyRestParams = (
supportsDone: boolean,
params: Array<any>,
test: Function,
) => supportsDone && params.length < test.length
? done => test(...params, done)
: () => test(...params);
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.
Yea, I usually have a lint rule to fix it for me :p
Codecov Report
@@ Coverage Diff @@
## master #6843 +/- ##
==========================================
- Coverage 63.43% 63.42% -0.01%
==========================================
Files 235 235
Lines 9115 9114 -1
Branches 4 4
==========================================
- Hits 5782 5781 -1
Misses 3332 3332
Partials 1 1
Continue to review full report at Codecov.
|
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
Currently
jest-each
assumes if a test callback has more arguments than supplied in the data (array/template) then the extra argument is adone
callback. This logic should not apply fordescribe
blocks as they do not supportdone
callbacks (or any args for that matter).Fixes: #6838
Test plan
Updated unit tests to check
describe
blocks aren't invoked withdone