Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Parametrized tests handling #26

Closed
botsman opened this issue Apr 15, 2020 · 8 comments
Closed

Parametrized tests handling #26

botsman opened this issue Apr 15, 2020 · 8 comments

Comments

@botsman
Copy link

botsman commented Apr 15, 2020

Hi!

As far as I can see, parametrized tests are not handled properly.

I am not quite sure if it is possible to explore all the test cases without executing the code though.
But maybe you could take a look at such a case.

Here is an example from the official jest documentation:

describe.each([
  [1, 1, 2],
  [1, 2, 3],
  [2, 1, 3],
])('.add(%i, %i)', (a, b, expected) => {
  test(`returns ${expected}`, () => {
    expect(a + b).toBe(expected);
  });

  test(`returned value not be greater than ${expected}`, () => {
    expect(a + b).not.toBeGreaterThan(expected);
  });

  test(`returned value not be less than ${expected}`, () => {
    expect(a + b).not.toBeLessThan(expected);
  });
});

These tests are displayed as a single test in the Test Explorer, not as a separate test case for every set of parameters:
image

Also, if I try to run either the whole test or a single test case, nothing happens: neither fail nor success.

Thank you for your work!

@rossknudsen
Copy link

Cool, sounds like an interesting case to handle. And thanks for providing an example.

@rossknudsen
Copy link

I have a feeling that this issue will be related to jest-community/jest-editor-support#29. We use jest-editor-support to parse the test files. There is an open PR jest-community/jest-editor-support#30 that I think will fix this issue. Maybe go and add your support for it there?

@botsman
Copy link
Author

botsman commented Apr 15, 2020

Yes, it looks like my issue is related to that in the jest-editor-support repository.
Closing this issue then as related to a 3rd party.

Thanks!

@botsman botsman closed this as completed Apr 15, 2020
@botsman
Copy link
Author

botsman commented Dec 21, 2020

@rossknudsen hi!

Can I ask you to update to the latest version of https://github.com/jest-community/jest-editor-support ?
It seems that the problem is resolved in the latest version.

Thanks!

@rossknudsen
Copy link

@botsman would you mind checking how much of the issues that you raised in this ticket are covered by the recent release of v0.8.0 to the marketplace? If you feel that this ticket has been covered, then please feel free to close. If there are some minor defects remaining, then you can either document here, or raise them in a separate issue (I'm easy either way).

@botsman
Copy link
Author

botsman commented Jan 19, 2021

I've checked the latest version with the extension with the base example from 1st message:

  1. In order to discover tests, I need to run them first.
    Before running:

image

After running:

image

If tests are intended to be explored only after execution, then it is fine.
  1. After tests are discovered, the first part of parametrized tests remains in the tests UI:
    image

Both of these issues are really minor for me.

Otherwise it looks good, great job guys!
Thank you!

@clabough
Copy link

clabough commented Mar 23, 2021

This is not working for me. Perhaps because I have nested describes? I have a parent describe that uses beforeEach to set things up for individual tests and I also have some parameterized tests in that describe like

describe.each([[' '], ['  '], [' - '], [', '], ["'"], [":'"]])(
    'inputValues setter should single quote the separator value, when it starts or ends with whitespace or single quote',
    (actualValue: string) => {
      it(` "${actualValue}"`, () => {
        component.inputValues = {separator: actualValue};
        expect(component.separatorInput).toEqual(`'${actualValue}'`);
      });
    }
  );

In this case, the Text Explorer panel just shows this before and after running the tests.
image

The reference test at the top of this issue gives me
image

@douglasg14b
Copy link

douglasg14b commented Jul 12, 2021

Doesn't work for me either, just stays the same after running.

Example copied directly from the docs: https://jestjs.io/docs/api#testeachtablename-fn-timeout

test.each([
  {a: 1, b: 1, expected: 2},
  {a: 1, b: 2, expected: 3},
  {a: 2, b: 1, expected: 3},
])('.add($a, $b)', ({a, b, expected}) => {
  expect(a + b).toBe(expected);
});

image

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

4 participants