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

fix: test.each() in vitest differs from jest #2280

Conversation

jfparadis-appomni
Copy link

Previously:

  • every test case was tested individually to see if it's an array,
  • if so, the test case was spread as test parameters (in the test callback function).

This PR makes test.each() follow the same algorithm as jest-each:

  • the array of test cases is first evaluated to see it's a table (an array of arrays),
  • if so, then all test cases are spread as test parameters, otherwise not.

This means for example that a single array in a series of test cases is not spread as test parameters.

Note that Jest pre-normalize the table, which we can still can avoid here, and process each row on the fly.
https://github.com/facebook/jest/blob/main/packages/jest-each/src/table/array.ts#L49

@sheremet-va
Copy link
Member

We already have an open PR #2064

@antfu
Copy link
Member

antfu commented Nov 7, 2022

Thank you for working on this! Close in favor of #2064

@antfu antfu closed this Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test.each() in vitest differs from jest
3 participants