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

Add full support for parametrized tests #427

Closed
andris-zalitis opened this issue Feb 25, 2019 · 12 comments · Fixed by #593 or #649
Closed

Add full support for parametrized tests #427

andris-zalitis opened this issue Feb 25, 2019 · 12 comments · Fixed by #593 or #649

Comments

@andris-zalitis
Copy link

Environment

  1. node -v: v11.10.0
  2. npm -v: 6.7.0
  3. npm ls jest: └── jest@24.1.0
  4. Operating system: macOS Mojave

Prerequisite

  • are you able to run jest test from command line? yes
  • how do you run your tests from command line? (for example: npm run test or node_modules/.bin/jest) npm test

Expected Behavior

When using syntax test.each(table)(name, fn, timeout) described here test status circles show the status of tests and failed test error appears in-line.

Actual Behavior

When using syntax test.each(table)(name, fn, timeout) test status circles are not shown and test errors are not displayed inline.

Workaround

If applying parametrization to describe with describe.each, test status information seems to be showed correctly.

In the image below all three tests should have been marked as failed. As it can be seen, the second does not show any test status information and the third (workaround) seems to work. Since I don't want to wrap all my separate tests into describe.each workaround is not that useful in my case.

screenshot 2019-02-25 at 10 34 51

@malnor
Copy link

malnor commented Mar 14, 2019

Was just looking for the same thing. it.each/test.each does not work, but it would be really helpful if it would. To use describe.each instead is not an applicable workaround for me as it defeats the purpose of having several things to test for one describe.

@dgreene1
Copy link

Upvote

@KyranRana
Copy link

Upvote and bump 👍

@hakubo
Copy link

hakubo commented May 15, 2020

upvote

@connectdotz
Copy link
Collaborator

for people who are interested in this issue, please try v4-alpha that should have addressed this issue.

@DScheglov
Copy link

DScheglov commented Jan 15, 2021

@connectdotz , I'm using vscode-jest-4.0.0-alpha.2.

it seams when there is only one it.each per describe the status is displayed correctly, when two or more the status is ?.

  1. node -v: v14.15.4
  2. npm -v: 6.14.11
  3. npm ls jest or npm ls react-scripts (if you haven’t ejected): jest@25.5.4
  4. your vscode-jest settings if customized:
    • jest.pathToJest? not customized
    • jest.pathToConfig? not customized
  5. OS: Ubuntu 20.04 (64 bit).
  6. Jest Config:
{
    "preset": "ts-jest",
    "testEnvironment": "node",
    "collectCoverage": true,
    "collectCoverageFrom": [
      "src/**/*.ts"
    ]
  }

Screenshot from 2021-01-15 13-12-52
Screenshot from 2021-01-15 13-14-16
Screenshot from 2021-01-15 13-25-05

describe('id', () => {
  it.each([
    [true],
    [false],
  ])('returns %s for %s', value => {
    expect(value).toBe(value);
  });
});
describe('not', () => {
  it.each([
    [true],
    [false],
  ])('%s not equal to reverse', value => {
    expect(!value).not.toBe(value);
  });
});

@connectdotz
Copy link
Collaborator

indeed we have some gaps to cover... see #649

@connectdotz connectdotz reopened this Jan 19, 2021
@connectdotz connectdotz mentioned this issue Jan 19, 2021
15 tasks
@connectdotz
Copy link
Collaborator

v4.0.0-alpha.3 is released today. The main change is to support the parameterized tests. Feel free to give this release a try and open new issues if needed...

@DScheglov
Copy link

v4.0.0-alpha.3 is released today. The main change is to support the parameterized tests. Feel free to give this release a try and open new issues if needed...

I will try it today some later. Thanks a lot for a quick fix!

@DScheglov
Copy link

DScheglov commented Jan 27, 2021

@connectdotz , hey

Now correctly works only the first in the file it.each:

Screenshot from 2021-01-27 21-20-33

And I guess the number of test-cases is displayed for whole file.

@connectdotz
Copy link
Collaborator

@DScheglov I tried your snippet above and all seems to be fine:

Screen Shot 2021-01-27 at 4 45 30 PM

Something else is at play here... which jest version your project is on? I should have mentioned that for parameterized tests to be properly reported, you need to have jest version >= 26.5.0 (see migration notes for alpha.3 release). Otherwise, can you post the relevant debug message from the developer console or OUTPUT channel?

@DScheglov
Copy link

@DScheglov I tried your snippet above and all seems to be fine:
Something else is at play here... which jest version your project is on? I should have mentioned that for parameterized tests to be properly reported, you need to have jest version >= 26.5.0 (see migration notes for alpha.3 release). Otherwise, can you post the relevant debug message from the developer console or OUTPUT channel?

Hey, @connectdotz thanks. I had 25.x.x version of jest. Upgrading it to the 26.6.3 helped. Now it works well.
Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants