testez
testez copied to clipboard
Add jest's describe.each
describe.each lets you pass in a table to parameterize any tests inside that describe block. Their example:
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);
});
});
For TestEZ, the format would probably need to be adapted a bit, and I don't like the idea of having describe() and describe.each() (describe is both a function and an object). Maybe describeEach() would fit our style better.
Worth noting that you can just put a describe block inside a for loop and parameterize tests that way, so this would only be to reduce boilerplate/extra indents, and to better document the intention.
Also consider it.each to avoid an extra indent if you don't need multiple cases for each input.