-
Notifications
You must be signed in to change notification settings - Fork 28.6k
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
test.each #53714
Comments
Can you clarify the "less pretty test names" and "requires more explicit exception handling" points? |
(Didn't mean to self-assign) |
Sure. The signature for
reviewing my current code I didn't find anything to backup those claims (I've since removed them from my post). Instead, here is an illustration of the difference. This can be currently done like: [].forEach((i) => {
describe(`with ${i} `, async () => {
[].forEach((j) => {
it(`with id ${j}`, async () => {
assert.ok(() => true);
});
});
});
}); vs how it might be done with a native support: describe.each([])("with %i", (i) => {
it.each([])("with id %i", async (j) => {
assert.ok(() => true);
});
}); |
Looking at it now, it seems to only be a few more lines to implement in userland rather than in core (though initially I did suggest adding this). |
Similar request for reference #47902 |
What is the problem this feature will solve?
Allows for duplicating the same test with different data
What is the feature you are proposing to solve the problem?
test.each(list)
, which does aforEach
on thelist
and runs the test once for each itemWhat alternatives have you considered?
Manually doing a for each. This has the drawback of more boilerplate
Prior art:
https://jestjs.io/docs/api#testeachtablename-fn-timeout
https://www.npmjs.com/package/mocha-each
The text was updated successfully, but these errors were encountered: