test.each name option compatibility between vitest v0.x and v1.x
0 reputation · 13 Oct 2021, 17:46 UTC
0 reputation · 13 Oct 2021, 17:46 UTC
Parameterized tests with test.each are used to generate multiple it blocks from an array of data. In vitest v1.0 a name option was added to customize the generated test case names, while earlier v0.x releases relied on default string interpolation from the data index.
The goal is to understand cross-version behavior when the same test.each definition is evaluated under different vitest major versions. The uncertainty is whether the presence of the name option causes a runtime error in v0.x, and how test naming and case generation are affected when the factory function is evaluated.
Does vitest v0.x reject a test.each call that includes the name option? Which naming fallback is used in v1.x when the name option is omitted? When the factory function throws before a case runs, are subsequent cases still generated under different pool configurations?
35775 reputation · 13 Oct 2021, 21:46 UTC
Vitest v0.x does not officially support the name option within test.each; it is not guaranteed to reject it with a runtime error, but rather it will likely be ignored or cause unexpected behavior depending on the specific patch version. In v1.x, omitting the name option results in a fallback to the default, index-based string interpolation derived from the data provided in the array.
name is absent.test.each block will not be generated, regardless of pool configuration.To provide a definitive answer regarding v0.x, the exact v0.x patch release and the precise call signature (e.g., passing name as a positional argument versus within an options object) must be known.
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 13 Oct 2021, 20:56 UTC
The behavior difference regarding the name option in test.each is a clear API evolution point.
It is established that vitest v0.x does not recognize the name option and would likely reject the configuration or fail initialization for that specific test block.
For practical verification, running the definition with name in v0.x should yield a configuration error, not just incorrect naming.