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

Don't append additional arguments in jest-each titles #6349

Closed
captbaritone opened this issue May 29, 2018 · 3 comments
Closed

Don't append additional arguments in jest-each titles #6349

captbaritone opened this issue May 29, 2018 · 3 comments

Comments

@captbaritone
Copy link
Contributor

captbaritone commented May 29, 2018

I found it confusing that values not used in the test table were appended to my template:

In my case, I needed some extra logic to determine my title, so I did this:

const table = testFiles.map(testFile => {
  const shouldPass = SHOULD_NOT_PASS_IN_JEST.has(testFile);
  const expectation = `${testFile} ${shouldPass ? 'errors' : 'passes'}`;
  const testName = `${expectation} when not in erroOnDeprecated mode`;
  return [testName, shouldPass, testFile];
});

test.each(table)('%s', (testName, shouldPass, testFile) => {
  const result = runJest('error-on-deprecated', [testFile]);
  expect(result.status).toBe(shouldPass ? 1 : 0);
});

And ended up with titles like this:

  ✓ fail.test.js errors when not in erroOnDeprecated mode true fail.test.js (541ms)
  ✓ jasmine.addMatchers.test.js passes when not in erroOnDeprecated mode false jasmine.addMatchers.test.js (526ms)
  ✓ jasmine.any.test.js passes when not in erroOnDeprecated mode false jasmine.any.test.js (527ms)
  ✓ jasmine.anything.test.js passes when not in erroOnDeprecated mode false jasmine.anything.test.js (519ms)
  ✓ jasmine.arrayContaining.test.js passes when not in erroOnDeprecated mode false jasmine.arrayContaining.test.js (521ms)
  ✓ jasmine.createSpy.test.js passes when not in erroOnDeprecated mode false jasmine.createSpy.test.js (553ms)
  ✓ jasmine.objectContaining.test.js passes when not in erroOnDeprecated mode false jasmine.objectContaining.test.js (536ms)
  ✓ jasmine.stringMatching.test.js passes when not in erroOnDeprecated mode false jasmine.stringMatching.test.js (506ms)
  ✓ pending.test.js passes when not in erroOnDeprecated mode false pending.test.js (509ms)
  ✓ spyOn.test.js passes when not in erroOnDeprecated mode false spyOn.test.js (551ms)
  ✓ spyOnProperty.test.js errors when not in erroOnDeprecated mode true spyOnProperty.test.js (537ms)
  ✓ DEFAULT_TIMEOUT_INTERVAL.test.js passes when not in erroOnDeprecated mode false DEFAULT_TIMEOUT_INTERVAL.test.js (531ms)

It was surprising to me that the unused arguments were appended. Could get extra confusing if the extra values were not easily serializable.

@mattphillips

@mattphillips
Copy link
Contributor

Pending: #6346

@captbaritone
Copy link
Contributor Author

Ah, should have searched!

Closing as dupe of #6342

@SimenB SimenB closed this as completed May 30, 2018
@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

No branches or pull requests

3 participants