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

test.each: Allow test name to not include every test arg #6342

Closed
wcauchois opened this issue May 29, 2018 · 6 comments · Fixed by #6346
Closed

test.each: Allow test name to not include every test arg #6342

wcauchois opened this issue May 29, 2018 · 6 comments · Fixed by #6346

Comments

@wcauchois
Copy link

wcauchois commented May 29, 2018

Regarding the test.each function:

Right now when you provide a test name, the arguments to the test from each are appended to that name even if you don't provide any placeholders, due to the behavior of util.format. For example, the test

test.each([
  'foo',
  'bar'
])('description of test', () => { /* ... */ })

would run the tests "description of test foo" and "description of test bar". Sometimes this is not desirable. For example, if the test arguments are long strings this would bloat the output.

Could we come up with a better formatting mechanism that would allow users more control over this behavior?

@wcauchois wcauchois changed the title Allow test name to not include every test arg test.each: Allow test name to not include every test arg May 29, 2018
@SimenB
Copy link
Member

SimenB commented May 29, 2018

@mattphillips ^

Related: #6321

@mattphillips
Copy link
Contributor

Strange I’ve not noticed this but I was using vsprint before instead of Node Util format I’d say this is definitely a bug. I’ll try and get this sorted ASAP

@wcauchois
Copy link
Author

@mattphillips That's awesome, thank you! Out of curiosity, why aren't you using sprintf? I took a look at the docs and it seems much more flexible than util.format.

@SimenB
Copy link
Member

SimenB commented May 30, 2018

#6266

(in general, not this specifically. And I'm not opposed to switching, I didn't think about these edge cases when suggesting util.format)

@wcauchois
Copy link
Author

Gotcha. Thanks again!

@github-actions
Copy link

This issue 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.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants