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

[jest-each]: Add flag to prevent done callback being supplied to describe #6843

Merged
merged 3 commits into from Aug 18, 2018

Conversation

mattphillips
Copy link
Contributor

Summary

Currently jest-each assumes if a test callback has more arguments than supplied in the data (array/template) then the extra argument is a done callback. This logic should not apply for describe blocks as they do not support done callbacks (or any args for that matter).

Fixes: #6838

Test plan

Updated unit tests to check describe blocks aren't invoked with done

test: Function,
) => {
if (supportsDone && params.length < test.length)
return done => test(...params, done);

return () => test(...params);
Copy link
Collaborator

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

Copy link
Contributor Author

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);

Copy link
Collaborator

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-io
Copy link

codecov-io commented Aug 14, 2018

Codecov Report

Merging #6843 into master will decrease coverage by <.01%.
The diff coverage is 82.35%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
packages/jest-jasmine2/src/each.js 0% <0%> (ø) ⬆️
packages/jest-each/src/bind.js 86.58% <100%> (-0.17%) ⬇️
packages/jest-each/src/index.js 77.77% <100%> (ø) ⬆️
packages/jest-circus/src/index.js 57.69% <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 4ebc778...9979f0e. Read the comment docs.

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"describe does not expect any arguments" received when incorrect number of arguments requested
5 participants