-
-
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] Fix each array title concatenation #6346
Conversation
f71d988
to
f610733
Compare
f610733
to
dd3f9fc
Compare
Codecov Report
@@ Coverage Diff @@
## master #6346 +/- ##
==========================================
+ Coverage 63.63% 63.65% +0.02%
==========================================
Files 226 226
Lines 8648 8654 +6
Branches 4 4
==========================================
+ Hits 5503 5509 +6
Misses 3144 3144
Partials 1 1
Continue to review full report at Codecov.
|
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.
LGTM
const arrayFormat = (str, ...args) => { | ||
const matches = (str.match(SUPPORTED_PLACEHOLDERS) || []).length; | ||
return util.format(str, ...args.slice(0, matches)); | ||
}; |
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.
what about matches.length > args.length
?
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.
.slice
is greedy and will take all of the args still, there will just be some placeholders that aren't replaced. Do we care about this case? I think it should be pretty obvious that the placeholders aren't replaced as there isn't a value for them 😆
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.
Should we throw? Probably not
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.
Not sure if it should fail the tests, I wouldn't say its an error case. Just a developer mistake, perhaps we could log a warning?
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.
Maybe we can add a lint rule for it?
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.
I like it 😄
Please rebase. |
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
Fixes #6342
Test plan
util.format